C Programming MCQs

Q1)  What is the output of the following code snippet?

#include

main()

{

short unsigned int i = 0;

printf(“%u\n”, i–);

}

A. 0

B. Compile error

C. 65535

D. 32767

Answer : A

Q2) What is the output of the following program?

#include 

main()

{   

int i = 1;      

while(++i <= 5)      

printf(“%d “,i++);}

A. 1 3 5

B. 2 4

C. 2 4 6

D. 2

Answer : B

Q3) Identify the invalid constant used in fseek() function as ‘whence’ reference.

A. SEEK_SET

B. SEEK_CUR

C. SEEK_BEG

D. SEEK_END

Answer : C

Q4) What is the output of the following program?

#include

main()

{

   fprintf(stdout,”Hello, World!”);

}

A. Hello, World!

B. No output

C. Compile error

D. Runtime error

Answer : C

Q5) What is the output of the following program?

#include

void main()

{

   char *s = “C++”;

   printf(“%s “, s);

   s++;

   printf(“%s”, s);

}

A. C++ C++

B. C++ ++

C. ++ ++

D. Compile error

Answer : B 

error: Content is protected !!