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

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

#include<stdio.h>

main()
{	
    register int x = 5;

    int *p;
    p=&x;
    x++;
    printf("%d",*p);
}

A - Compile error

B - 5

C - 6

D - Garbage value

Answer : A

Explanation

Compile error, we cannot take the address of a register variable.

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

#include<stdio.h>

main()
{
   printf("\");
}

A - \

B - \"

C - "

D - Compile error

Answer : D

Explanation

Compile error, Format string of printf is not terminated.

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

#include<stdio.h>

main()
{
   int i = 1;
   
   Charminar:
   printf("%d ",i++);
   if(i==3) break;
   if(i<=5) goto Charminar;
}

A - 1 2

B - 1 2 3

C - 1 2 4 5

D - Compile error

Answer : D

Explanation

Compile error, wrong place for ‘break’ to appear.

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

#include<stdio.h>

main()
{	
   fprintf(stdout,"Hello, World!");
}

A - Hello, World!

B - No output

C - Compile error

D - Runtime error

Answer : C

Explanation

stdout is the identifier declared in the header file stdio.h, need to include the same.

Q 5 - C is the successor of ___ programming language.

A - C++

B - B++

C - B

D - Mini C

Answer : C

Explanation

B is a programming language developed at Bell Labs in 1969. It is derived from BCPL (Basic Combined Programming Language). It is designed by Ken Thompson with Dennis Ritchie.

Q 6 - In Windows & Linux, how many bytes exist for near, far and huge pointers?

A - Near: 1, far: 4, huge: 7

B - near: 4, far: 4, huge: 4

C - near: 0, far: 4, huge: 4

D - near: 4, far: 5, huge: 6

Answer : B

Explanation

In DOS, numbers of byte exist for near pointer = 2, far pointer = 4 and huge pointer = 4.

In Windows and Linux, numbers of byte exist for near pointer = 4, far pointer = 4 and huge pointer = 4.

Answer : B

Explanation

Standard error stream (Stderr) = Any program use it for error messages and diagnostics issue.

Q 8 - The return keyword used to transfer control from a function back to the calling function.

A - Yes

B - Switch

C - go back

D - goto

Answer : A

Explanation

In C, the return function stops the execution of a function and returns control with value to the calling function. Execution begins in the calling function by instantly following the call.

Q 9 - What will be the output of the following program?

#include<stdio.h>

int main()
{
   const int i = 0;
    
   printf("%d\n", i++);
   return 0;
}

A - 100

B - Infinity

C - 0

D - Return error

Answer : D

Explanation

It is because ++needs a value and a const variable can’t be modified.

#include<stdio.h>

int main()
{
   const int i = 0;
    
   printf("%d\n", i++);
   return 0;
}

Q 10 - Choose the function that is most appropriate for reading in a multi-word string?

A - strnset()

B - scanf()

C - strchr()

D - gets()

Answer : D

Explanation

gets (); = Collects a string of characters terminated by a new line from the standard input stream stdin


cprogramming_questions_answers.htm

Advertisements