MIDTERM EXAMINATION
Fall 2008
CS201- Introduction to Programming (Session - 2)
Time: 60 min
M a r k s: 38
Question No: 1 ( M a r k s: 1 ) http://vuzs.net
What is the output of the following statement?
int i = 2.5; do { cout i * 2; } while (i > 3 && i < 10);
► 510
► 5
► 48
► error
Question No: 2 ( M a r k s: 1 ) http://vuzs.net
What does !(7) evaluate to in decimal where ! is a NOT operator?
► 7
► 8
► 9
► 10
Question No: 3 ( M a r k s: 1 ) http://vuzs.net
The condition in while loop may contain logical expression but not relational expression.
► True
► False
Question No: 4 ( M a r k s: 1 ) http://vuzs.net
Searching is easier when an array is already sorted
►
►
Question No: 5 ( M a r k s: 1 ) http://vuzs.net
If an array has 100 elements, what is allowable range of subscripts?
►0 - 99
► 1 - 99
► 0 - 100
► 1 - 100
Question No: 6 ( M a r k s: 1 ) http://vuzs.net
What will be the value of ‘a’ and ‘b’ after executing the following statements?
a = 3;
b = a++;
► 3, 4
► 4, 4
► 3, 3
► 4, 3
Question No: 7 ( M a r k s: 1 ) http://vuzs.net
What will be the correct syntax to initialize all elements of two-dimensional array to value 0?
► int arr[2][3] = {0,0} ;
► int arr[2][3] = {{0},{0}} ;
► int arr[2][3] = {0},{0} ;
► int arr[2][3] = {0} ;
Question No: 8 ( M a r k s: 1 ) http://vuzs.net
Which of the following functionreturns the size of a string variable?
►strlength()
►stringlen()
►strlen()
►strLength()
Question No: 9 ( M a r k s: 1 ) http://vuzs.net
What will be the range of numbers generated by function rand () % 9?
► 0 to 9
►1 to 9
►0 to 8
►1 to 8
Question No: 10 ( M a r k s: 1 ) http://vuzs.net
►
►
►
►
Question No: 11 ( M a r k s: 1 ) http://vuzs.net
Computer can understand only machine language code.
►
►
Question No: 12 ( M a r k s: 1 ) http://vuzs.net
►
►
►
►
Question No: 13 ( M a r k s: 1 ) http://vuzs.net
What does 5 ^ 6 , evaluate to in decimal where ‘^’ is Exclusive OR operator?
►
►
►
►
Question No: 14 ( M a r k s: 1 ) http://vuzs.net
If the file is not properly closed in the program, the program ____________.
►Terminate normally
►Indicate Runtime error
►Indicate Compile time error
►Crashes
Question No: 15 ( M a r k s: 1 ) http://vuzs.net
Which of the following header file include string conversion functions?
►string.h
►stdlib.h
►ctype.h
►sconvert.h
Question No: 16 ( M a r k s: 1 ) http://vuzs.net
In Program commenting the code liberally is
►
►
►
►
Question No: 17 ( M a r k s: 1 )
Which header file must be included while handling files?
Question No: 18 ( M a r k s: 1 )
What is meant by C++ statement: const int *ptr = &x;
Question No: 19 ( M a r k s: 2 )
What is a truth Table?
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?
Question No: 21 ( M a r k s: 5 )
What are similarities and differences between Structures and Unions?
Question No: 22 ( M a r k s: 10 )
Write a void function( ); that takes integer numbers from the user and then displays the sum of odd and even numbers entered by the user. Your program should terminate if user enters a negative number