C & C++ Programming Multiple Choice Questions - Set 37

1.       Consider the statements a = 13 ; c = a<< 3 ; (a and c are integers). The result assigned to the integer c is :
(A) 104
(B) 114  
(C) 140
(D) 14
Answer: A
2.       A stream is a sequence of
(A) Integers
(B) File names
(C) Bytes
(D) Classes
Answer: C
3.       Only the address of the object is transferred to the function
(A) Pass-by-reference
(B) Pass-by-pointer
(C) Pass-by-value
(D) None of the above
Answer: A
4.       Which of the following c operators has the highest precedence?
(A) ++
(B) %                 
(C) Ü
(D) &&
Answer: A
5.       The number of elements in a 2-D array a [-5..5, 5..10] is
(A) 44
(B) 55                
(C) 66
(D) 77
Answer: C

6.       Which one of the following special symbols is allowed in a variable name?
(A) | (pipeline)
(B) * (asterisk)
(C) - (hyphen)
(D) _ (underscore)
Answer: D
7.       Literal means
(A) a string
(B) a string constant
(C) a character
(D) an alphabet
Answer: B
8.       Choose the correct answer
(A) Casting refers to implicit type conversion
(B) Coercion refers to implicit type conversion
(C) Casting means coercion
(D) Coercion refers to explicit type conversion
Answer: B
9.       printf (“%d”, printf (“tim”));
(A) results in a syntax error
(B) outputs tim3
(C) outputs garbage
(D) outputs tim and terminates abruptly
Answer: B
printf statement will print tim3, “tim” due to inner printf statement and 3 as length due to
outer printf statement.
10.    Output of the following program fragment is
x = 5;
y = x++;
printf(“%d%d”, x, y);
(A) 5, 6
(B) 5, 5
(C) 6, 5
(D) 6, 6
Answer: C
x is incremented by 1 and before that increment the value is assigned to y so value of x=6 and y=5.

Post a Comment