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

1.       If a function is declared as void fn(int *p), then which of the following statements is valid to call function fn?
(A) fn(x) where x is defined as int x;
(B) fn(x) where x is defined as int *x;
(C) fn(&x) where x is defined as int *x;
(D) fn(*x) where x is defined as int *x;
Answer: B
Explanation:
Function void fn(int *p) needs pointer to int as argument. When x is defined as int *x, then x is pointer to integer and not *x.
2.       Set precision requires the ................ header file.
(A) stdlib.h        (B) iomanip.h
(C) console.h   (D) conio.h
Answer: B
3.       The memory address of the first element of an array is called ..................
(A) floor address          (B) foundation address
(C) first address           (D) base address
Answer: D
4.       A variable P is called pointer if ....................
(A) P contains the address of an element in DATA.
(B) P points to the address of first element in DATA
(C) P can store only memory addresses
(D) P contain the DATA and the address of DATA
Answer: A
5.       Find out the error in following code. If (x = 100)
(A) 100 should be enclosed in quotations.
(B) There is no semicolon at the end of first line.
(C) Equals to operator mistake.
(D) Variable x should not be inside quotation.
Answer: C

6.       Looping in a program means ..................
(A) jumping to the specified branch of program.
(B) repeat the specified lines of code.
(C) testing for the condition.
(D) jumping without checking the condition.
Answer: B
7.       The difference between while structure and do structure for looping is .................
(A) in while statement the condition is tested at the end of first iteration
(B) in do structure the condition is tested at the beginning of first iteration
(C) the do structure decides whether to start the loop code or not whereas while statement decides whether to repeat the code or not
(D) in while structure condition is tested before executing statements inside loop where as in do structure condition is tested before repeating the statements inside loop
Answer: D
8.       Which of the following is not a valid statement regarding stringstream?
(A) Stringstream is defined in the header file <sstream>.
(B) It allows string based objects treated as stream.
(C) It is especially useful to convert strings to numerical values and vice versa.
(D) none of above.
Answer: D
9.       Which of the header file must be included to use stringstream?
(A) <iostream>              (B) <string>
(C) <sstring>                 (D) <sstream>
Answer: D
10.    Which of the following header file does not exist?
(A) <iostream>              (B) <string>
(C) <sstring>                 (D) <sstream>
Answer: C


Post a Comment

0 Comments