C Programming - Online Quiz


Advertisements

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers
cprogramming_questions_answers.htm

Q 1 - What is the outpout of the following program?

#include<stdio.h>

main() 
{
      enum { india, is=7, GREAT };

      printf("%d %d", india, GREAT);
}

A - 0 1.

B - 0 2

C - 0 8

D - Compile error

Answer : C

Explanation

0 8, enums gives the sequence starting with 0. If assigned with a value the sequence continues from the assigned value.

Q 2 - What is the output of the following program?

#include<stdio.h>

{ 
   int x = 1;
   switch(x) 
   {
      default: printf("Hello");
      case 1: printf("hi"); break;
   }
}

A - Hello

B - Hi

C - HelloHi

D - Compile error

Answer : B

Explanation

Hi, control reaches default-case after comparing the rest of case constants.

Q 3 - What is the output of the following program?

#include<stdio.h>

main()
{ 
   int i = 13, j = 60;
   
   i ^= j;
   j ^= i;
   i ^= j;
   
   printf("%d %d", i, j);
}

A - 73 73

B - 60 13

C - 13 60

D - 60 60

Answer : B

Explanation

60 13, its swapping.

Q 4 - Which of the following is used in mode string to open the file in binary mode?

A - a

B - b

C - B

D - bin

Answer : B

Explanation

To perform unformatted data I/O a file is opened in binary mode and is represented with the alphabet ‘b’ in the mode string.

Q 5 - What is the output of the following program?

#include<stdio.h>

main()
{ 
   int x;
   float y;
   
   y = x = 7.5;
   printf("x=%d y=%f", x, y);
}

A - 7 7.000000

B - 7 7.500000

C - 5 7.500000

D - 5 5.000000

Answer : A

Explanation

‘x’ gets the integral value from 7.5 which is 7 and the same is initialized to ‘y’.

Q 6 - In the standard library of C programming language, which of the following header file is designed for basic mathematical operations?

A - math.h

B - conio.h

C - dos.h

D - stdio.h

Answer : A

Explanation

math.h is a header file in the standard library designed for basic mathematical operations

Q 7 - Which standard library function can return a pointer to the last occurrence of a character in a string?

A - stchar()

B - strrchr()

C - strchar() & stchar()

D - strrchar()

Answer : B

Explanation

The strrchr() function finds string for the last occurrence of a character and place the pointer to the last occurrence of character.

Answer : A

Explanation

In C programming, the fflush() function writes any unwritten data in stream's buffer. If, stream is a null pointer, fflush() function will flush all streams with unwritten data in the buffer.

int fflush(FILE *stream);

Answer : B

Explanation

As per the operators preference.

Q 10 - In the given below statement, what does the “pf” indicate?

   int (*pf)();

A - pf is a pointer of a function which return int

B - pf is a pointer

C - pf is a function pointer

D - None of the above

Answer : A

Explanation

pf is a pointer as well holds some functions reference.

Advertisements