CS201 Fall 2011 Final Term Feb 2012 – VU Current Paper – 13 Feb 2012

Mcqs were easy and from past papers.

Write down the syntax in two different ways to initialize character array with string ‘programming’. 2

Write the C++ code for the declaration of overloaded stream insertion(>>) and stream extraction() operator for the object d of type Date. 2 marks

What happens when an object is assigned to another object without overloading an assignment operator? 2 marks

Suppose there is a template function ‘func’ having argument of type U and return type T. What will be the C++ syntax to call this function, when we pass a variable ‘x’ of type double and it is returning an int type? 2 marks

If the requested memory is not available in the system then what does calloc(), malloc() and new operator return? 3 marks

Which one of the given two methods is better to read from a file and Why ? 3 marks

Using stream insertion operator >>
Using get() function

Write a function named Sum which takes an integer as its argument and uses a static integer variable to keep track of the sum of all values passed to it during the running of a program. 3 marks

Given is the code for nested classes.
class First
{
public:

class Second
{ public:
Second()
{
fValue = 20;
}
void Display();
private:
int fValue;
};
};

Write the code to define Display() member function of class inner class outside the body of outer class. The function Display() will display the value of data member fValue of class First. 3marks

Briefly explain the logic of given code. Also determine what is the value of ‘counter’ variable if the code below is executed ? 5 marks
main()
{
int num = 5;
int counter=0;
while(num != 0)
{
if ( num & 01)
counter++;
num>>=1;
}
return 0;
}

Using Template (code given) have to write a function square() that takes “x” as double but return its square as integer. 5marks

One question was from the phone example in the handouts. Have to write part of missing code . 5marks

Using manipulation operator show
Virtual——–university (8 – character between them) 5 marks

DOWNLOAD SOLUTION HERE
loading...