We are Permanently Move to www.VUpk.net Please Join us there.

CS201 Mid Term Solved Paper 2009 - 5

Friday 3 August 2012
MIDTERM EXAMINATION
Spring 2009
CS201- Introduction to Programming

Question No: 1      ( M a r k s: 1 ) http://vuzs.net
In C/C++ the #include is called,
Header file
Preprocessor Directive
Statement
Function
Question No: 2      ( M a r k s: 1 ) http://vuzs.net
When the logical operator AND (&&) combine two expressions exp1 and exp2 then the result will be true only,
When both exp1 and exp2 are true
When both exp1 and exp2 are false
When exp1 is true and exp2 is false
When exp1 is false and exp2 is true
Question No: 3      ( M a r k s: 1 ) http://vuzs.net
Header file: fstream.h includes the definition of the stream classes.
ifstream, fstream, cout
ifstream, fstream, ofstream
fstream, cin, cout
None of the above
Question No: 4      ( M a r k s: 1 ) http://vuzs.net
How many parameter(s) function getline() takes?
0
1
2
3
istream& istream::getline( char* buffer, streamsize num, char delim ); 
Question No: 5      ( M a r k s: 1 ) http://vuzs.net
Disks is divided into ____________ with power of__________.
Chunks, 2
Chunks, 2n
Blocks, n2
Blocks, 2n

Question No: 6      ( M a r k s: 1 ) http://vuzs.net
Function seekg() takes ____________ parameter(s).
0
1
2
3
istream& seekg ( streamoff off, ios_base::seekdir dir );
Question No: 7      ( M a r k s: 1 ) http://vuzs.net
Keyword ‘array’ must be used to declare an array.
True
False
Question No: 8      ( M a r k s: 1 ) http://vuzs.net
What will be the value of x after executing following
switch(x){ case 1:
x += 1 ;
break ;
case 2:
x += 2 ; case 3:
x +=3 ;
break ; }
2
4
5
7
it wil be 7 as every case will add value to x
Question No: 9      ( M a r k s: 1 ) http://vuzs.net
When a function finishes its execution then,
The control return to its Prototype
The control returns to its definition
Control returns to statement following function call
The compiler stop execution of whole program
Question No: 10      ( M a r k s: 1 ) http://vuzs.net
What will be the output of following code segment?
main(){
int x = 5 ;
{
int x = 4 ;
cout << x << “,” ;
}
cout << x ;
}



4, 4
4, 5
5, 4
First call of x read local value which is 4 and next call is to x has value of 5
Question No: 11      ( M a r k s: 1 ) http://vuzs.net
When an array element is passed to a function then this array element is pass function,
By reference
By data type
By value
By data

A single array element is like a variable, so when an array element is passed to a function, then by default it is passed by val


Question No: 12      ( M a r k s: 1 ) http://vuzs.net
Which of the following operator is used to access the value of variable pointed to by a pointer?
* operator
-> operator
&& operator
& operator
Question No: 13      ( M a r k s: 1 ) http://vuzs.net
The       also belong to the System Software category.
True
False
Question No: 14      ( M a r k s: 1 ) http://vuzs.net
The argument of the isdigit() function is
a character,
a C-string,
a C++ string class variable
None of the given options.
Question No: 15      ( M a r k s: 1 ) http://vuzs.net
Declaring structures does not mean that memory is allocated.
True
False
Question No: 16      ( M a r k s: 1 ) http://vuzs.net
A union is a user-defined data type that contains only__________ from its list of members at
a time.
One object
Two objects
Three objects
None of the given options
Question No: 17      ( M a r k s: 1 )
What does 7 ^ 5 evaluate to in decimal and binary?
Question No: 18      ( M a r k s: 1 )
How can we evaluate a program?
Then the program should be evaluated by testing and checking
Question No: 19      ( M a r k s: 2 )
Which variable will be used in inner code block if we have the same names of variable at
outer code block and inner code block?
It will use inner block variable
Question No: 20      ( M a r k s: 3 )
What will happen if we omit braces within loop?
Loop will execute only single immediate line and complete the iteration. You can not run group of lines without use of curly braces.
Question No: 21      ( M a r k s: 5 )
Read the program below and write the output.
#include
main()
{
ofstream outfile;
char outfilename[] = “abc.txt”;
char outputtext[50] = “Welcome to VU”
outfile.open(outfilename, ios::out);
if(!outfile)
{
cout<<”Error Occured”;
exit(1);
}
outfile<<"Hello Buddies..."<outfile.close(); }
Program should not run as ofstream funcations are used, which are define in header file so program did not load that header file.
If we assume all libraries are loaded and referenced properly.
Then this program
Will create  file name abc.txt
If its already exit it will overwrite it and
Write the “Hello Buddies...Welcome to VU” in that file and close it.
Question No: 22      ( M a r k s: 10 )
Differentiate between C and c++
C++ was based on C and retains a great deal of the functionality. C++
does not retain complete source-level compatability with C.
There are a few  gotchas for C++ programmers trying to write C code, and
C programmers trying to compile with a C++ compiler.
Actually c is a procedural programming language which 
cann't face the real world problem. It has some drawback 
like a global data is shared by all function and if in a 
large program it is find out difficult that which function 
uses which data. 
 
On the other hand c++ is an object oriented programming 
language which eliminate some pitfall of conventional or 
procedural programming language. It is a concept or 
approach for designing a new software. It is nothing to do 
with any programming language although a programming 
language which support the oops concept to make it easier 
to implement.
 
This is the main different between c and c++.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...