FINALTERM EXAMINATION
Spring 2010
CS201- Introduction to Programming
Time: 90 min
M a r k s: 58
Question No: 1 ( M a r k s: 1 ) http://vuzs.net
&& is -------------------- operator.
► An arithmetic
► Logical
► Relational
► Unary
Question No: 2 ( M a r k s: 1 ) http://vuzs.net
Which of the following function(s) is/are included in ctype.h header file?
► isdigit(int c)
► isxdigit(int c )
► tolower(int c)
► All of the above
Question No: 3 ( M a r k s: 1 ) http://vuzs.net
► Electro-physical, 6
► Electro-Mechanical, 4
► Electro-physical, 5
► Electro-Mechanical, 7
Question No: 4 ( M a r k s: 1 ) http://vuzs.net
All preprocessor directives are started with the symbol______.
► *
► +
► @
► #
Question No: 5 ( M a r k s: 1 ) http://vuzs.net
When we use manipulators in our program then which header file should be included?
► iostream.h
► stdlib.h
► stdio.h
► iomanip.h
Question No: 6 ( M a r k s: 1 ) http://vuzs.net
setprecision is a parameter less manipulator.
► True
► False
Question No: 7 ( M a r k s: 1 ) http://vuzs.net
Which of the following is NOT a preprocessor directive?
► #error
► #define
► #line
► #ndefine
Question No: 8 ( M a r k s: 1 ) http://vuzs.net
We can do arithmetic with references like pointers.
► True
► False
Question No: 9 ( M a r k s: 1 ) http://vuzs.net
What does (*this) represents?
► The current function of the class
► The current pointer of the class
► The current object of the class
► A value of the data member
Question No: 10 ( M a r k s: 1 ) http://vuzs.net
Friend function of a class is ______________ .
► Member function
► Non-member function
► Private function
► Public function
Question No: 11 ( M a r k s: 1 ) http://vuzs.net
A function can declare itself a friend of a class.
► True
► False
Question No: 12 ( M a r k s: 1 ) http://vuzs.net
Overloaded delete operator function takes the same parameter as an argument returned by new operator function.
► True
► False
Question No: 13 ( M a r k s: 1 ) http://vuzs.net
The second parameter of operator functions for << and >> are objects of the class for which we are overloading these operators.
► True
► False
Question No: 14 ( M a r k s: 1 ) http://vuzs.net
A template function must have at least ---------- generic data type
► Zero
► One
► Two
► Three
Question No: 15 ( M a r k s: 1 ) http://vuzs.net
A template function must have only generic data types.
► True
► False
Question No: 16 ( M a r k s: 1 ) http://vuzs.net
We can not make a member function of a class as template function.
► True
► False
Question No: 17 ( M a r k s: 1 ) http://vuzs.net
Which character is inserted at the end of string to indicate the end of string?
► new line
► tab
► null
► carriage return
Question No: 18 ( M a r k s: 1 ) http://vuzs.net
Assignment operator is used for ___________.
► calculation
► reading
► assigning value to variables
► None of the given options.
Question No: 19 ( M a r k s: 1 ) http://vuzs.net
The object _______________may be used both for file input and file output
► fstream,
► ifstream,
► ofstream,
► none of the given options.
Question No: 20 ( M a r k s: 1 ) http://vuzs.net
Which of the following function calling mechanism is true for the function prototype given below?
float func(float &);
► Call by value
► Call by reference using pointer
► Call by reference using reference variable
► None of the given options
Question No: 21 ( M a r k s: 1 ) http://vuzs.net
The programs, in which we allocate static memory, run essentially on ________
► Heap
► System Cache
► None of the given options
► Stack
Question No: 22 ( M a r k s: 1 ) http://vuzs.net
Overloaded delete operator function takes parameter of void pointer and returns ________.
► void
► void pointer
► pointer to an object
► pointer of type int
Question No: 23 ( M a r k s: 1 ) http://vuzs.net
What should be the return type of the constructor?
► void pointer
► int
► same as object type
► constructors do not return any thing
Question No: 24 ( M a r k s: 1 ) http://vuzs.net
It is a way of reusing the code when we contain objects of our already written classes into a new class,
► True
► False
Question No: 25 ( M a r k s: 1 ) http://vuzs.net
Templates are not type safe.
► true
► false
Question No: 26 ( M a r k s: 1 ) http://vuzs.net
The functions used for dynamic memory allocation return pointer of type ______
► int
► float
► void
► double
Question No: 27 ( M a r k s: 2 )
Write a declaration statement for an array of 10 elements of type float. Include an initialization statement of the first four elements to 1.0, 2.0, 3.0 and 4.0.
Answer:
float floatArry[10] = {1.0,2.0,3.0,4.0};
Question No: 28 ( M a r k s: 2 )
Write the general syntax for the declaration of pre-increment and post-increment member operator function.
Classname operator ++(); ---- pre increment
Classname operator ++(int) ---- post increment
Question No: 29 ( M a r k s: 2 )
What is difference between endl and \n?
Endl is manipulator and it insert new line character and flush the stream.
\n is control charcter which is used to insert linebreak
Question No: 30 ( M a r k s: 2 )
What does code optimization mean?
It is process by which we make over code such a way that it improves the speed of program. By use of optimization we refine program codes in such a way that it run faster and consume less memory. We do it in such a way that output quality is not compromised
Question No: 31 ( M a r k s: 3 )
How is the following cout statement interpreted by compiler?
cout << a << b << c ;
It will give a compiler error because a,b,c are not declared.
Question No: 32 ( M a r k s: 3 )
Suppose an object of class A is declared as data member of class B.
(i) The constructor of which class will be called first? Answer : A
(ii) The destructor of which class will be called first? Answer : B
Question No: 33 ( M a r k s: 3 )
Define static variable. Also explain life time of static variable?
Question No: 34 ( M a r k s: 5 )
What is difference between Unary and binary operators and how they can be overloaded?
Opertaror is keyword
Question No: 35 ( M a r k s: 5 )
What steps we must follow to design good program?
Question No: 36 ( M a r k s: 5 )
Write a program which defines five variables which store the salaries of five employees, using setw and setfill manipulators to display all these salaries in a column.
Note: Display all data with in a particular width and the empty space should be filled with character x
Output should be displayed as given below:
xxxxxx1000
xxxxxx1500
xxxxx20000
xxxxx30000
xxxxx60000
Answer:
#include <iostream.h>
#include <iomanip.h>
main(){
int sal1 =1000;
int sal2 =1500;
int sal3 =20000;
int sal4 =30000;
int sal5 =60000;
cout << setfill ('x') << setw (10);
cout<< sal1<<endl;
cout << setfill ('x') << setw (10);
cout<< sal2<<endl;
cout << setfill ('x') << setw (10);
cout<< sal3<<endl;
cout << setfill ('x') << setw (10);
cout<< sal4<<endl;
cout << setfill ('x') << setw (10);
cout<< sal5<<endl;
int i=0;
cin>>i; // to stop the screen to show the output
}