CS201 Mid Term Paper 2010 - 3

MIDTERM  EXAMINATION
Spring 2010 Paper
CS201- Introduction to Programming
Time: 60 min
 
 
Question No: 1      ( M a r k s: 1 ) http://vuzs.net
 
 
Compiler is a
 
System software
 
► Application Software
 
Driver
 
Editor

 
 
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
 
 
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: 4      ( M a r k s: 1 ) http://vuzs.net
 
 
To access the data members of structure _______ is used.
dot operator (.)
* operator
 operator
None of given.
 
Question No: 5      ( M a r k s: 1 ) http://vuzs.net
The address operator (&) can be used with,
Statement
Expression
Variable
Constant
Question No: 6      ( M a r k s: 1 ) http://vuzs.net
Both compiler and interpreter are used to translate program into machine language code.
True
False
 
Question No: 7      ( M a r k s: 1 ) http://vuzs.net
Missing semicolon ‘;’ at the end of C++ statement is
Logical error
Syntax error
Runtime error
None of the given options

 
 
Question No: 8      ( M a r k s: 1 ) http://vuzs.net
 
 
Switch statement is an alternative of _________ statement
 
multiple if
 
continue
 
break
 
goto

 
Question No: 9      ( M a r k s: 1 ) http://vuzs.net 
 
 
Array is passed by value to a function by default.
 
True
 
False
 
Question No: 10      ( M a r k s: 1 ) http://vuzs.net 
 
Which of the following is the correct function call having array named student of 10 elements as a parameter.
 
addRecord(student[]) ;
 
addRecord(student) ;
    
addRecord(student[10]) ;
 
addRecord(*student) ;
 
 
Question No: 11      ( M a r k s: 1 ) http://vuzs.net 
 
 
What will be the result of expression x%= 2, if x = 7?
 
x = 1
 
x = 3
 
x = 7
 
x = 2

 
Question No: 12      ( 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 <
}
cout <
}
 
 
5, 5
 
4, 4
 
4, 5
 
5, 4

 
 
Question No: 13      ( 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: 14      ( 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: 15      ( M a r k s: 1 ) http://vuzs.net 
 
 
What's wrong with this for loop?
for (int k = 2, k
 
the increment should always be ++k
 
the variable must always be the letter i when using a for loop
 
there should be a semicolon at the end of the statement
 
► the commas should be semicolons(
( Princess,vuzs,apr11) 
 
Question No: 16      ( M a r k s: 1 ) http://vuzs.net 
 
 
Let suppose
 
Union intorDouble{ 
Int ival; 
Double charvar; 
};  
 
main(){ 
intorDouble  VAZ; 
int size ; 
size = sizeof(VAZ); 
} 
 
What will be the value of variable "size", if int occupies 4 bytes and double occupies 8 bytes?
 
 
2
 
4
 
8
 
12

 
Question No: 17      ( M a r k s: 2 ) 
 
 
How a program can use a function? 
 
Answer:  Calling program need to write the name of function and provide the arguments without the data types of arguments. 
 
When we call a function we don’t give data type of retuning variable or for arguments. 
 
Question No: 18      ( M a r k s: 2 ) 
 
 
Which function is used to read/write more than a single character or single line while handling files?
We use the getline function to read more than single charcter
 
Question No: 19      ( M a r k s: 2 ) 
 
 
Suppose the pointer yptr is pointing to the first element of the array y and the size of array is 10. Can we increment the yptr up to 12 times? And what will happen?
 
It may carry the memory address which which  is not readable.. we can increment it.
 
 
Question No: 20      ( M a r k s: 3 ) 
 
 
(i) An array day is declared as: int day[] = {1, 2, 3, 4, 5, 6, 7};
How many elements does array 'day' has?
(ii) If the declaration is changed as: int day[7] = {1, 2, 3, 4, 5, 6, 7};
How many elements does array 'day' has?
 
In both the case array day will have the 7 elements. Of int type 
 
Question No: 21      ( M a r k s: 3 ) 
 
 
What is the difference between tellg() and tellp() functions?
tellg()
 
tellg ()    : function gives us the current get position of the file pointer. It returns a whole number of type long, which is the position of the next character to be read from that file.
 
tellp()     function is used to determine the next position to write a character while writing into a file. It also returns a long number
 
Question No: 22      ( M a r k s: 5 ) 
 
Write code which read a string not greater than 20 characters from keyboard stored it in an array Name and display it on the screen.
 
Question No: 23      ( M a r k s: 5 ) 
 
Write a C/C++ program which defines an array of 15 elements. This program changes all uppercase letters of an array into lowercase letters and all lowercase letters to uppercase using Character handling functions.
 
# include
# include
main(){
char myarray[15] = {'a','b','c'} ;
for (int i = 0;i
 
if  (isupper(myarry[i])
 
{myarray[i] = tolower(myarray[i]);}
 
{myarray[i] = toupper(myarray[i]);}
 
}
 
 
}

Leave a Reply

Related Posts Plugin for WordPress, Blogger...