Thursday, 11 August 2016

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

1.       Which of the following is not an escape sequence?
(A) \n      (B) \r
(C) \’       (D) \p
Answer: D
\p is not an escape sequence.
2.       .............. provides multiway branching.
(A) for                 (B) if
(C) if else          (D) switch
Answer: D
3.       Variables that are declared, but not initialized, contain ................
(A) blank spaces                      (B) zeros
(C) "garbage" values              (D) nothing - they are empty
Answer: C
4.       The output of the following statements is
char ch[6]={‘e’, ‘n’, ‘d’, ‘\0’, ‘p’};
printf(“%s”, ch);
(A) endp            (B) end0p
(C) end              (D) error
Answer: C
printf statement will print end because string is terminated at “\0” and in array after d, we have null character.
5.       The void type is used for
(A) Returning the value         (B) creating generic pointers
(C) Creating functions            (D) Avoid error
Answer: B
The void type is used to create generic pointers.

6.       The valid octal constants from the following
(i) 0245 (ii) 0387          (iii) 04.32        (iv) -0467
(A) (i) and (ii)                (B) (iii) and (iv)
(C) (ii) and (iii)              (D) (i) and (iv)
Answer: D
(i) and (iv) are valid octal constants.
7.       What is the following program doing?
main ()
{ int d = 1;
printf(“%d\n”, d++);
while (d < = 9);}
(A) Adding 9 integers                          (B) Adding integers from 1 to 9
(C) Displaying integers from 1 to 9   (D) None of these
Answer: C
d starting from 1 is incrementing one by one till d=9 so the printf statement is printing numbers from 1 to 9.
8.       ............... operator links a class to a member.
(A) : :                  (B) .
(C) ->                  (D) *
Answer: A
9.       An array of pointers is same as .................
(A) pointer to array                   (B) pointers to pointers
(C) pointer to function                        (D) pointer to structure
Answer: B
10.    What is the output of the following program segment ?
long i = 65536;
printf(“%d\n”, i);
(A) 0       (B) 65536
(C) -1      (D) 65
Answer: A


Post a Comment