Explore topic-wise MCQs in C Programming.

This section includes 117 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.

101.

A char variable can store either an ASCII character or a Unicode character.

A. 1
B.
Answer» B.
102.

What will be the output of the program? #include int main() { int x = 10, y = 20; if(!(!x) && x) printf("x = %d\n", x); else printf("y = %d\n", y); return 0; }

A. y =20
B. x = 0
C. x = 10
D. x = 1
Answer» D. x = 1
103.

What will be the output of the program? #include int main() { char str[]="C-program"; int a = 5; printf(a >10?"Ps\n":"%s\n", str); return 0; }

A. C-program
B. Ps
C. Error
D. None of above
Answer» B. Ps
104.

Which of the following errors would be reported by the compiler on compiling the program given below? #include int main() { int a = 5; switch(a) { case 1: printf("First"); case 2: printf("Second"); case 3 + 2: printf("Third"); case 5: printf("Final"); break; } return 0; }

A. There is no break statement in each case.
B. Expression as in case 3 + 2 is not allowed.
C. Duplicate case case 5:
D. No error will be reported.
Answer» D. No error will be reported.
105.

Point out the error, if any in the program. #include int main() { int P = 10; switch(P) { case 10: printf("Case 1"); case 20: printf("Case 2"); break; case P: printf("Case 2"); break; } return 0; }

A. Error: No default value is specified
B. Error: Constant expression required at line case P:
C. Error: There is no break statement in each case.
D. No error will be reported.
Answer» C. Error: There is no break statement in each case.
106.

Point out the error, if any in the while loop. #include int main() { int i=1; while() { printf("%d\n", i++); if(i>10) break; } return 0; }

A. There should be a condition in the while loop
B. There should be at least a semicolon in the while
C. The while loop should be replaced with for loop.
D. No error
Answer» B. There should be at least a semicolon in the while
107.

Which of the following statements are correct about the below C-program? #include int main() { int x = 10, y = 100%90, i; for(i=1; i<10; i++) if(x != y); printf("x = %d y = %d\n", x, y); return 0; } 1 : The printf() function is called 10 times. 2 : The program will produce the output x = 10 y = 10 3 : The ; after the if(x!=y) will NOT produce an error. 4 : The program will not produce output.

A. 1
B. 2, 3
C. 3, 4
D. 4
Answer» C. 3, 4
108.

The modulus operator cannot be used with a long double.

A. 1
B.
Answer» B.
109.

How many times the while loop will get executed if a short int is 2 byte wide? #include int main() { int j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; }

A. Infinite times
B. 255 times
C. 256 times
D. 254 times
Answer» C. 256 times
110.

Point out the error, if any in the for loop. #include int main() { int i=1; for(;;) { printf("%d\n", i++); if(i>10) break; } return 0; }

A. There should be a condition in the for loop
B. The two semicolons should be dropped
C. The for loop should be replaced with while loop.
D. No error
Answer» E.
111.

Which of the following statements are correct about the below program? #include int main() { int i = 10, j = 20; if(i = 5) && if(j = 10) printf("Have a nice day"); return 0; }

A. Output: Have a nice day
B. No output
C. Error: Expression syntax
D. Error: Undeclared identifier if
Answer» D. Error: Undeclared identifier if
112.

In mathematics and computer programming, which is the correct order of mathematical operators ?

A. Addition, Subtraction, Multiplication, Division
B. Division, Multiplication, Addition, Subtraction
C. Multiplication, Addition, Division, Subtraction
D. Addition, Division, Modulus, Subtraction
Answer» C. Multiplication, Addition, Division, Subtraction
113.

The way the break is used to take control out of switch and continue to take control of the beginning of the switch?

A. Yes
B. No
C. Yes
D. No
Answer» C. Yes
114.

What will be the output of the program? #include int main() { int i=0; for(; i<=5; i++); printf("%d", i); return 0; }

A. 0, 1, 2, 3, 4, 5
B. 5
C. 1, 2, 3, 4
D. 6
Answer» E.
115.

A short integer is at least 16 bits wide and a long integer is at least 32 bits wide.

A. 1
B.
C. 1
D.
Answer» B.
116.

Which of the following is not logical operator?

A. &
B. &&
C. ||
D. !
Answer» B. &&
117.

How many times "IndiaBIX" is get printed? #include int main() { int x; for(x=-1; x<=10; x++) { if(x < 5) continue; else break; printf("IndiaBIX"); } return 0; }

A. Infinite times
B. 11 times
C. 0 times
D. 10 times
Answer» D. 10 times