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

1.       Which of the following is not a valid escape code?
(A) \t       (B) \v
(C) \f       (D) \w
Answer: D
2.       The function that allocates requested size of bytes and returns a pointer to the first byte of the allocated space is:
(A) realloc         (B) malloc
(C) calloc           (D) none of the above
Answer: B
Explanation:
malloc allocates requested size of bytes and returns a pointer to the first byte of the allocated space.
3.       C language was invented by
(A) Abacus        (B) Charles babage
(C) Thomson    (D) Dennis Ritchie
Answer: D
4.       The given FOR loop is
for ( ; ; )
{
printf(“ ”);
}
(A) valid             (B) indefinite
(C) invalid         (D) displays runtime errors
Answer: D
Explanation:
The given for loop displays runtime errors because no test condition is given. Test condition is must inside for loop.
5.       Which of the following statement is true about a function?
(A) An invoking function must pass arguments to the invoked function.
(B) Every function returns a value to the invoker.
(C) A function may contain more than one return statement.
(D) Every function must be defined in its own separate file.
Answer: A
Explanation:
An invoking function must pass arguments to the invoked function.

6.       What is the output of the following program?
main( )
{
int i=4, z=12;
if(i=5 || z>50)
printf(“hello”);
else
printf(“hye”);
}
(A) hello                        (B) hye
(C) syntax error            (D) hellohye
Answer: A
Explanation:
i=5 will assign value 5 to i so the if statement (i=5||z>50) is true so “printf” statement will print hello.
7.       The ............. statements are simply a group of related statements that are treated as a single unit.
(A) block            (B) multiple
(C) related         (D) logical
Answer: A
8.       Code is contained in .............. of the class.
(A) object           (B) template
(C) function      (D) array
Answer: C
9.       ................ operator links the name of the object with the name of the member.
(A) ->                  (B) .(Dot)
(C) &                  (D) *
Answer: B
10.    Each object has its own copies of the class .................
(A) data              (B) code
(C) function      (D) instance variables
Answer: D


Post a Comment

0 Comments