CS201 Current Finalterm Papers
Virtual Position Forum :: STUDY CORNER :: Study Matters :: VU Current Exam Papers :: FinalTerm Papers
Page 1 of 1 • Share
CS201 Current Finalterm Papers
Cs 201
2 Feb 2012 Final Term
Long Question
Q1: Given is the code for a class named Coordinate.(10)
class Coordinate
{
private:
int X, Y;
public:
Coordinate()
{
X = 0;
Y = 0;
}
class Coordinate
{
friend void Displaycord();
private:
int X, Y;
public:
Coordinate()
{
X = 0;
Y = 0;
}
};
Q2: Write a program that defines a Template function named Square () which finds the square of a number and then return it. Define one variable of type int in main function and then call Square function on that. (10)
Program output should look like this:
Enter an integer value to find its Square: 6
Square of integer number is: 36
Q3: Why is it necessary to initialize a static object as the time of creation and how it is initialized ?(5)
Q4:Transform the following If-else statement into switch statement.(5)
if (x == 5)
...
else if (x == 10 || x == 11)
...
else if (x ==
...
else if (x == 9)
...
else
...
Q5:Read the given code and explain code functionality. (3)
Matrix :: Matrix ( const Matrix & m )
{
numRows = m.numRows ;
numCols = m.numCols ;
elements = new ( double * ) [ numRows ] ;
for ( int i = 0 ; i < numRows ; i ++ )
{
elements [ i ] = new double [ numCols ] ;
for ( int j = 0 ; j < numCols ; j ++ )
elements [ i ] [ j ] = m.elements [ i ] [ j ] ;
}
}
Hint : This function belong to a matrix class, having
Number of Rows = numRows
Number of Columns = numCols
Q6: In the following code;(3)
#include
#include
main() {
double j;
getche();
}
Is double j; an example of global variable or local variable ? Why ?
Q7: Identify and correct the error in the given code segment.(3)
main()
{
int val = 30;
int &ref = val;
&ref = &ref++;
}
Q8: Determine the output of the given program code.(2)
for (int I = 1; i<5; i++){
if ( I == 3)
continue;
cout << I << endl ;
}
Q9: What is the output of following code snippet.(2)
// class templates
#include
using namespace std;
template
class mypair {
T a, b;
public:
mypair (T first, T second)
{a=first; b=second;}
T getmax ();
};
template
T mypair::getmax ()
{
T retval;
retval = a>b? a : b;
return retval;
}
int main () {
mypair myobject (100, 75);
cout << myobject.getmax();
system("pause");
}
Q10: How can we declare and initialize static data member of a class?(2)
Q11: When memory is allocated dynamically using new operator within the constructor of class then what is an appropriate place to de-allocate the memory?(2)
Q11: Write down the output of the following code segment? (2)
int x[10] = {0,1, 2, 3, 4, 5, 6, 7, 8, 9};
int *xptr;
xptr = &x[5];
cout << *(xptr++) + 1;
MCQ
Sequence of event(s) when allocating memory using new operator is ____________.
Assignment operator is ________ associative
To avoid dangling reference, always return _________.
Which value is returned by the destructor of a class?
The functions used for dynamic memory allocation return pointer of type ______.
The function free() returns back the allocated memory got through calloc and malloc to _____ .
At the time of linking, library functions are available in the ________form.
Which of the following is NOT a preprocessor directive?
When we define an array of objects then ___________.
A constructor will create a new object with a full copy of the other object, this type of copy is known as ___________.
When an object of a class is defined inside another class then ______________.
Every stream has _________.
_________in the following options is not a method of output stream.
To perform manipulation with input/output, we have to include ________ header file
A class whose object is contained as const object, must have ____________.
By using objects as class members, _________ is achieved
The operator function will be implemented as _____, if both objects (obj1, obj2) are passed as arguments to - operator in the statement given below.
obj3 = obj1 - obj2;
ANSI stands for _________.
A template function must have at least _______________ generic data type.
Which of the following is true about operator overloading?
1-The operator works with only objects of the class in which it is overloaded.
2-The operator works with objects and primitive data types regardless of parameters.
3-The operator works with both objects and primitive data types depending on parameters.
4-The operator must have a constant and an object as parameters.
Operator overloading can be performed through__________________.
The pointer returned by the new operator points to ___________ of memory chunks allocated by the new operator.
The return type of the operator function for << operator is __________.
What will be the output of following statement?
cout << setfill(‘0’) << setw(7) << 128 ;
The operator used for casting in C is standard ________ operator.
Consider the following code segment.
struct intorDouble
{
Int ival;
Double charvar;
};
main()
{
intorDouble VAZ;
int size ;
size = sizeof(VAZ);
}
What will be the value of variable size if integer occupies 4 bytes and double occupies 8 bytes?
The file-open mode __________ is used to open a file for output and move to the end of the file.
In the statement int &x = y; compiler ______.
Which header file must be included to use the functions tolower() and toupper()?
Which one of the following functions is included in stdlib.h header file?
For one byte, there are _____ combinations of values which can be stored in computer.
Which of the following statement is best regarding declaration of friend function?
Answer- It can be declared anywhere in class as these are not affected by the public and private keywords.
The operator used for dereferencing the elements of an array using a pointer is _________.
The __________ statement forces the immediate next iteration of the loop.
A function is a block of statements (code) that can be __________.
Which of the following values are used in C/C++ to represent true and false?
Ans- 1 and 0
The dynamic memory allocation uses memory from the ____________.
In C/C++, null character is represented as ________________.
2 Feb 2012 Final Term
Long Question
Q1: Given is the code for a class named Coordinate.(10)
class Coordinate
{
private:
int X, Y;
public:
Coordinate()
{
X = 0;
Y = 0;
}
class Coordinate
{
friend void Displaycord();
private:
int X, Y;
public:
Coordinate()
{
X = 0;
Y = 0;
}
};
Q2: Write a program that defines a Template function named Square () which finds the square of a number and then return it. Define one variable of type int in main function and then call Square function on that. (10)
Program output should look like this:
Enter an integer value to find its Square: 6
Square of integer number is: 36
Q3: Why is it necessary to initialize a static object as the time of creation and how it is initialized ?(5)
Q4:Transform the following If-else statement into switch statement.(5)
if (x == 5)
...
else if (x == 10 || x == 11)
...
else if (x ==
...
else if (x == 9)
...
else
...
Q5:Read the given code and explain code functionality. (3)
Matrix :: Matrix ( const Matrix & m )
{
numRows = m.numRows ;
numCols = m.numCols ;
elements = new ( double * ) [ numRows ] ;
for ( int i = 0 ; i < numRows ; i ++ )
{
elements [ i ] = new double [ numCols ] ;
for ( int j = 0 ; j < numCols ; j ++ )
elements [ i ] [ j ] = m.elements [ i ] [ j ] ;
}
}
Hint : This function belong to a matrix class, having
Number of Rows = numRows
Number of Columns = numCols
Q6: In the following code;(3)
#include
#include
main() {
double j;
getche();
}
Is double j; an example of global variable or local variable ? Why ?
Q7: Identify and correct the error in the given code segment.(3)
main()
{
int val = 30;
int &ref = val;
&ref = &ref++;
}
Q8: Determine the output of the given program code.(2)
for (int I = 1; i<5; i++){
if ( I == 3)
continue;
cout << I << endl ;
}
Q9: What is the output of following code snippet.(2)
// class templates
#include
using namespace std;
template
class mypair {
T a, b;
public:
mypair (T first, T second)
{a=first; b=second;}
T getmax ();
};
template
T mypair
{
T retval;
retval = a>b? a : b;
return retval;
}
int main () {
mypair
cout << myobject.getmax();
system("pause");
}
Q10: How can we declare and initialize static data member of a class?(2)
Q11: When memory is allocated dynamically using new operator within the constructor of class then what is an appropriate place to de-allocate the memory?(2)
Q11: Write down the output of the following code segment? (2)
int x[10] = {0,1, 2, 3, 4, 5, 6, 7, 8, 9};
int *xptr;
xptr = &x[5];
cout << *(xptr++) + 1;
MCQ
Sequence of event(s) when allocating memory using new operator is ____________.
Assignment operator is ________ associative
To avoid dangling reference, always return _________.
Which value is returned by the destructor of a class?
The functions used for dynamic memory allocation return pointer of type ______.
The function free() returns back the allocated memory got through calloc and malloc to _____ .
At the time of linking, library functions are available in the ________form.
Which of the following is NOT a preprocessor directive?
When we define an array of objects then ___________.
A constructor will create a new object with a full copy of the other object, this type of copy is known as ___________.
When an object of a class is defined inside another class then ______________.
Every stream has _________.
_________in the following options is not a method of output stream.
To perform manipulation with input/output, we have to include ________ header file
A class whose object is contained as const object, must have ____________.
By using objects as class members, _________ is achieved
The operator function will be implemented as _____, if both objects (obj1, obj2) are passed as arguments to - operator in the statement given below.
obj3 = obj1 - obj2;
ANSI stands for _________.
A template function must have at least _______________ generic data type.
Which of the following is true about operator overloading?
1-The operator works with only objects of the class in which it is overloaded.
2-The operator works with objects and primitive data types regardless of parameters.
3-The operator works with both objects and primitive data types depending on parameters.
4-The operator must have a constant and an object as parameters.
Operator overloading can be performed through__________________.
The pointer returned by the new operator points to ___________ of memory chunks allocated by the new operator.
The return type of the operator function for << operator is __________.
What will be the output of following statement?
cout << setfill(‘0’) << setw(7) << 128 ;
The operator used for casting in C is standard ________ operator.
Consider the following code segment.
struct intorDouble
{
Int ival;
Double charvar;
};
main()
{
intorDouble VAZ;
int size ;
size = sizeof(VAZ);
}
What will be the value of variable size if integer occupies 4 bytes and double occupies 8 bytes?
The file-open mode __________ is used to open a file for output and move to the end of the file.
In the statement int &x = y; compiler ______.
Which header file must be included to use the functions tolower() and toupper()?
Which one of the following functions is included in stdlib.h header file?
For one byte, there are _____ combinations of values which can be stored in computer.
Which of the following statement is best regarding declaration of friend function?
Answer- It can be declared anywhere in class as these are not affected by the public and private keywords.
The operator used for dereferencing the elements of an array using a pointer is _________.
The __________ statement forces the immediate next iteration of the loop.
A function is a block of statements (code) that can be __________.
Which of the following values are used in C/C++ to represent true and false?
Ans- 1 and 0
The dynamic memory allocation uses memory from the ____________.
In C/C++, null character is represented as ________________.
laila- Monstars
-
Posts : 422
Join date : 2011-11-09
Age : 31
Location : Pak
Character sheet
Experience:
(50/500)
Similar topics
» FIN621 Current Finalterm papers
» MGT613 Current Finalterm papers
» CS601 Current Finalterm papers
» MCM515 Current Finalterm papers
» MTH202 Current Finalterm papers
» MGT613 Current Finalterm papers
» CS601 Current Finalterm papers
» MCM515 Current Finalterm papers
» MTH202 Current Finalterm papers
Virtual Position Forum :: STUDY CORNER :: Study Matters :: VU Current Exam Papers :: FinalTerm Papers
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Yesterday at 10:48 am by ali001
» Storybook Magic App
Tue Apr 30, 2024 7:06 pm by ali001
» Flower Book Match3 Puzzle Game
Tue Apr 30, 2024 12:17 pm by ali001
» Avian Influenza Symptom in Chickens "Bird Flu H5N1 Virus" Vet learning materials, Poultry Farming
Sat Apr 27, 2024 9:57 am by Ibad Khan Buledi
» house disrepair claims
Mon Apr 22, 2024 11:23 am by Joshuaadam
» Aloha Planner - Note-Taker
Thu Apr 11, 2024 4:52 pm by ali001
» Streaming Guide Film TV Series
Tue Apr 09, 2024 9:39 pm by ali001
» Apricot Tree Problems & Solutions ????|خوبانی کے پھل کو کیڑا لگنےسے بچانے کا طریقہ ????
Sun Apr 07, 2024 6:28 am by Zamaan Khan
» خوبانی کے پودے کی کاشت گرم علاقوں میں کرنی چاہیے یا نہی
Sun Apr 07, 2024 6:24 am by Zamaan Khan