MCQOPTIONS
Saved Bookmarks
This section includes 175 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. |
What is the difference between the following 2 codes?//Program 1#include <stdio.h> int main() { int n3, n1 = 2, n2 = 3; n3 = n1++ + ++n2; printf("%d %d %d", n3, n1, n2); }//Program 2#include <stdio.h> int main() { int n3, n1 = 2, n2 = 3; n3 = n1++ + +++n2; printf("%d %d %d", n3, n1, n2); } |
| A. | Space does make a difference, values of n1, n2, n3 are different |
| B. | No difference as space doesn t make any difference, values of n1, n2, n3 are same in both the case |
| C. | Program 2 has syntax error, program 1 is not |
| D. | Program 1 has syntax error, program 2 is not |
| E. | None of these |
| Answer» D. Program 1 has syntax error, program 2 is not | |
| 102. |
What will be the output of the following C code?#include <stdio.h> void main() { int p = 5; int q = ++p + p++ + --p; printf("Value of q is %d", q); } |
| A. | Value of q is 19 |
| B. | Value of q is 18 |
| C. | Value of q is 17 |
| D. | Value of q is 5 |
| E. | None of these |
| Answer» B. Value of q is 18 | |
| 103. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 5; if (n & (n = 6)) printf("True %d n", n); else printf("False %d n", n); } |
| A. | True 5 |
| B. | False 5 |
| C. | False 6 |
| D. | Compilation Error |
| E. | True 6 |
| Answer» F. | |
| 104. |
What will be the output of the following C code?#include <stdio.h> void main() { int num1 = 5; int num2 = 10 % 3 * 12 / 4; printf("Value of num is %d", num2); } |
| A. | Value of num is 0 |
| B. | Value of num is 1 |
| C. | Value of num is 2 |
| D. | Value of num is 3 |
| E. | None of these |
| Answer» E. None of these | |
| 105. |
What will be the output of the following C code?#include <stdio.h> int main() { int n1 = 2, n2 = 2, n3; n3 = n1++ + n2; printf("%d, %d", n1, n2); } |
| A. | 2 |
| B. | 3, 2 |
| C. | 2, 3 |
| D. | Compilation Error |
| E. | None of these |
| Answer» C. 2, 3 | |
| 106. |
What will be the output of the following C code? #include <stdio.h> int main() { int p = 2, q = 2, r = 2; printf("%d, %d, %d", ++p + ++p + p++, p++ + ++q, ++r + r++ + p++); } |
| A. | 2, 2, 2 |
| B. | 6, 9, 18 |
| C. | 9, 6, 18 |
| D. | 18, 6, 9 |
| E. | None of these |
| Answer» E. None of these | |
| 107. |
What will be the output of the following C code?#include <stdio.h> void main() { int num = 7.5 % 3; printf("Value of x is %d", num); } |
| A. | Value of num is 7.5 |
| B. | Value of num is 3 |
| C. | Value of num is 2.0 |
| D. | Compilation Error |
| E. | None of these |
| Answer» E. None of these | |
| 108. |
What will be the output of the following C code?#include <stdio.h> int main() { int p = 3; if (4 |(p = 4)) printf("p is %d n", p); else printf("%d n", p); } |
| A. | p is 3 |
| B. | Compilation Error |
| C. | Runtime Error |
| D. | Garbage value |
| E. | p is 4 |
| Answer» F. | |
| 109. |
What will be the final value of x in the following C code?#include <stdio.h> void main() { int num = 11 * 6 / 5 + 23; } |
| A. | 11 |
| B. | 36 |
| C. | 5 |
| D. | 23 |
| E. | Depends on compiler |
| Answer» C. 5 | |
| 110. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 15, m = 15; if (n = 10) m--; printf("%d, %d", n, m--); } |
| A. | 15, 15 |
| B. | 14, 10 |
| C. | 10, 15 |
| D. | 10, 14 |
| E. | None of these |
| Answer» E. None of these | |
| 111. |
What will be the output of the following C code?#include <stdio.h> int main() { int k = -13; k = k / 3; printf("%d n", k); return 0; } |
| A. | -13 |
| B. | 3 |
| C. | -4 |
| D. | All of above |
| E. | None of these |
| Answer» D. All of above | |
| 112. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = -7; if (!0 == 1) printf("Yes n"); else printf("No n"); } |
| A. | Compilation Error |
| B. | Runtime Error |
| C. | Garbage value |
| D. | Yes |
| E. | No |
| Answer» E. No | |
| 113. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ int a = 9, b, c; b = --a; c = a--; printf ( "%d %d %d n", a, b, c); return 0;} |
| A. | 9 8 8 |
| B. | 9 8 7 |
| C. | 8 8 7 |
| D. | 7 8 8 |
| E. | 7 7 8 |
| Answer» E. 7 7 8 | |
| 114. |
Which of the following statements are correct about the code snippet given below?int number = 10;int p = number > 5 ? p = 30; |
| A. | First; is treated as a null statement |
| B. | Second; is treated as a statement terminator |
| C. | 30 would be assigned to p |
| D. | Compiler would report an error |
| Answer» E. | |
| 115. |
Which of the following is the correct output for the program given below ?#include <stdio.h>int main ( ){ int x = 10, y = 20, z; z = (x == 10 || y > 20); printf ( "z = %d n", z); return 0;} |
| A. | z = 100 |
| B. | z = 200 |
| C. | z = 1 |
| D. | z = 0 |
| E. | z = 300 |
| Answer» D. z = 0 | |
| 116. |
Which of the following is the correct output for the program given below ?#include <stdio.h>int main ( ){ int a = 12, b = 7, c; c = a != 4 || b == 2; printf ("c = %d n" , c); return 0;} |
| A. | c = 0 |
| B. | c = 1 |
| C. | c = 4 |
| D. | c = 2 |
| Answer» C. c = 4 | |
| 117. |
Which of the following is the correct output for the program given below? #include <stdio.h>int main ( ){ int a = 4, b = -1, c = 0, p, q, r, s; p = a || b || c; q = a && b && c; r = a || b && c; s = a && b || c; printf ("%d %d %d %d n", p, q, r, s); return 0;} |
| A. | 1 1 1 1 |
| B. | 1 1 0 1 |
| C. | 1 0 0 1 |
| D. | 0 1 1 1 |
| E. | 1 0 1 1 |
| Answer» F. | |
| 118. |
What will be the output of the following C code?#include <stdio.h> int main() { if (~2 == 3) { printf("Yes n"); } else { printf("No n"); } } |
| A. | Compilation Error |
| B. | Runtime Error |
| C. | Garbage value |
| D. | Yes |
| E. | No |
| Answer» F. | |
| 119. |
What will be the output of the following C code?#include <stdio.h> int main() { int k = 13; k = k / 3; printf("%d n", k); return 0; } |
| A. | 13 |
| B. | 3 |
| C. | 4 |
| D. | All of above |
| E. | None of these |
| Answer» D. All of above | |
| 120. |
What will be the output of the following C code?#include <stdio.h> int main() { int k = 2; int L = k++ + k; printf("%d n", L); } |
| A. | Compilation Error |
| B. | Runtime Error |
| C. | 2 |
| D. | 5 |
| E. | None of these |
| Answer» E. None of these | |
| 121. |
Which of the following is the correct output for the program given below? #include <stdio.h>int main ( ){ int a, b, c; a = b = c = 1; c = ++a || ++b && ++c; printf ( "a = %d b = %d c = %d n", a , b, c); return 0;} |
| A. | a = 2 b = 1 c = 1 |
| B. | a = 2 b = 2 c = 2 |
| C. | a = 2 b = 2 c = 1 |
| D. | a = 1 b = 2 c = 1 |
| Answer» B. a = 2 b = 2 c = 2 | |
| 122. |
What will be the output of the following C code?#include <stdio.h> void main() { int p = -6; int s = (p++, ++p); printf("%d n", s); } |
| A. | 6 |
| B. | -6 |
| C. | 4 |
| D. | -4 |
| E. | Compilation Error |
| Answer» E. Compilation Error | |
| 123. |
What will be the output of the following C code?#include <stdio.h> void main() { int n = 5; int *ptr = &n; int *q = ptr++; int r = ptr - q; printf("%d", r); } |
| A. | Compilation Error |
| B. | 5 |
| C. | 1 |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 124. |
What will be the output of the following C code? #include <stdio.h> void main() { int p = 6, q, r; q = --p; r = p--; printf("%d %d %d", p, q, r); } |
| A. | 5 5 4 |
| B. | 5 4 5 |
| C. | Compilation Error |
| D. | 4 5 5 |
| E. | None of these |
| Answer» E. None of these | |
| 125. |
What will be the output of the following C code?#include <stdio.h> void main() { int n1 = 100; int n2 = sizeof(n1++); printf("n1 is %d", n1); } |
| A. | n1 is 100 |
| B. | Compilation Error |
| C. | Runtime Error |
| D. | Garbage value |
| E. | None of these |
| Answer» B. Compilation Error | |
| 126. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = -5; n = n >> 2; printf("%d n", n); } |
| A. | -5 |
| B. | 2 |
| C. | Compilation Error |
| D. | -2 |
| E. | Either -1 or 1 |
| Answer» E. Either -1 or 1 | |
| 127. |
What will be the output of the following C code?#include <stdio.h> int main() { int num = 7; num = num << 2; printf("%d n", num); } |
| A. | 28 |
| B. | 7 |
| C. | 2 |
| D. | Compilation Error |
| E. | None of these |
| Answer» B. 7 | |
| 128. |
What will be the output of the following C code?#include <stdio.h> void main() { int n = -7; int p = (n++, ++n); printf("%d n", p); } |
| A. | -7 |
| B. | Compilation Error |
| C. | -5 |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 129. |
What will be the output of the following C code?#include <stdio.h> void main() { int num1 = 7, num2 = -9, num3 = 3, num4; num4 = ++num1 && ++num2 || ++num3; printf("%d %d %d %d", num1, num2, num3, num4); } |
| A. | 8 -8 3 1 |
| B. | 1 3 8 -8 |
| C. | 1 8 -8 3 |
| D. | 8 1 3 -8 |
| E. | None of these |
| Answer» B. 1 3 8 -8 | |
| 130. |
What will be the output of the following C code?#include void main() { int n = 6; int *ptr1 = &n; int *ptr2 = ptr1++; int Res = ptr1 - ptr2; printf("%d", Res); } |
| A. | 1 |
| B. | 6 |
| C. | Compilation Error |
| D. | Runtime Error |
| E. | None of these |
| Answer» B. 6 | |
| 131. |
Comment on the output of the following C code.#include <stdio.h> int main() { int k, num, x = 6; scanf("%d", &num); for (k = 0; k < num; k++) num = num * 3; } |
| A. | Bitwise exclusive OR |
| B. | Arithmetic Shift right |
| C. | Logical Shift left |
| D. | No output |
| E. | None of these |
| Answer» E. None of these | |
| 132. |
What will be the output of the following C code?#include <stdio.h> int main() { int num = 4; if (num >> 2) printf("%d n", num); } |
| A. | 2 |
| B. | Compilation Error |
| C. | 4 |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 133. |
What will be the output of the following C code?#include <stdio.h> int main() { if (7 & 8) printf("All"); if ((~7 & 0x000f) == 8) printf("that glitters is not gold. n"); } |
| A. | All |
| B. | All that glitters is not gold |
| C. | that glitters is not gold |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 134. |
What will be the output of the following C code?#include <stdio.h> int main() { int k = 3; int L = ++k + k; printf("%d n", L); } |
| A. | 3 |
| B. | Compilation Error |
| C. | 8 |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 135. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = 12; int m = n / -5; int p = n % -5; printf("%d %d n", m, p); return 0; } |
| A. | -2 |
| B. | 2 |
| C. | 2 -2 |
| D. | -2 2 |
| E. | None of these |
| Answer» E. None of these | |
| 136. |
What will be the output of the following C code? #include <stdio.h> int main() { unsigned int num = 20; num = ~num; printf("%d n", num); } |
| A. | -21 |
| B. | Compilation Error |
| C. | 20 |
| D. | Runtime Error |
| E. | None of these |
| Answer» B. Compilation Error | |
| 137. |
What will be the output of the following C code? |
| A. | 3 4 4 |
| B. | 4 4 3 |
| C. | 4 3 3 |
| D. | 4 3 4 |
| E. | Compilation Error |
| Answer» B. 4 4 3 | |
| 138. |
What will be the output of the following C code?#include <stdio.h> int main() { int n = -5; int m = n % 2; printf("%d n", m); } |
| A. | -1 |
| B. | 1 |
| C. | Compilation Error |
| D. | Runtime Error |
| E. | None of these |
| Answer» B. 1 | |
| 139. |
What will be the output of the following C code?#include <stdio.h> void main() { int num1 = 99; int num2 = sizeof(num1++); printf("num1 is %d", num1); } |
| A. | num1 is 97 |
| B. | num1 is 98 |
| C. | num1 is 99 |
| D. | Compilation Error |
| E. | None of these |
| Answer» D. Compilation Error | |
| 140. |
What will be the output of the following C code?#include <stdio.h> int main() { int k = 12; int *ptr = &k; printf("%d n", *ptr++); } |
| A. | Compilation Error |
| B. | 12 |
| C. | Runtime Error |
| D. | Address of k |
| E. | None of these |
| Answer» C. Runtime Error | |
| 141. |
What will be the output of the following C code?#include <stdio.h> int main() { int k = 1; int n = k++, m = ++k; printf("%d % d n", n, m); return 0; } |
| A. | 1 |
| B. | 3 |
| C. | 3 1 |
| D. | 1 3 |
| E. | None of these |
| Answer» E. None of these | |
| 142. |
What will be the output of the following C code?#include <stdio.h> int main() { int k = 3; int k = k++ + k; printf("%d n", k); } |
| A. | 3 |
| B. | 4 |
| C. | 5 |
| D. | Compilation Error |
| E. | None of these |
| Answer» E. None of these | |
| 143. |
Which of the following is the correct order of calling functions in the code snippet given below?a = f1 (10, 20 ) * f2 (30/40) + f3(); |
| A. | f1, f2, f3 |
| B. | f3, f2, f1 |
| C. | The order may vary from compiler to compiler |
| D. | None of the above |
| Answer» D. None of the above | |
| 144. |
Which of the following is the correct output for the program given below?#include <stdio.h>int main ( ){ int a = 25; printf ("%d %d %d n",a <= 20, a = 15, a >= 10); return 0;} |
| A. | 1 15 1 |
| B. | 1 20 1 |
| C. | 1 25 0 |
| D. | 1 1 1 |
| E. | 0 0 0 |
| Answer» B. 1 20 1 | |
| 145. |
Which of the following is correct order of evaluation for the expression given below ? |
| A. | * / % + - = |
| B. | = * / % + - |
| C. | / * % - + = |
| D. | * / % - + = |
| E. | - % / * + = |
| Answer» B. = * / % + - | |
| 146. |
What will be the final values of p and q in the following C statement? (Initial values: p = 2, q = 1) |
| A. | p = 1, q = 2; |
| B. | p = 2, q = 2; |
| C. | p = 2, q = 2; |
| D. | p = 0, q = 0; |
| E. | None of these |
| Answer» E. None of these | |
| 147. |
What will be the final values of p and q in the following C code? |
| A. | k value is 0 and L value is 0 |
| B. | k and L value are undefined |
| C. | Compilation Error |
| D. | Runtime Error |
| E. | None of these |
| Answer» D. Runtime Error | |
| 148. |
What will be the final values of k and L in the following C code? |
| A. | k value is 0 and L value is 0 |
| B. | Compilation Error |
| C. | k value is 1 and L value is 1 |
| D. | Runtime Error |
| E. | None of these |
| Answer» B. Compilation Error | |
| 149. |
What will be the output of the following C function? |
| A. | 2 3 |
| B. | 2 3 4 |
| C. | 2 3 4 5 6 7 |
| D. | 5 6 7 |
| E. | 5 6 |
| Answer» D. 5 6 7 | |
| 150. |
What will be the final value of c in the following C code snippet? (Initial values: p = 1, q = 2, r = 1) |
| A. | r = 2 |
| B. | r = 3 |
| C. | r = 1 |
| D. | Syntax Error |
| E. | None of these |
| Answer» B. r = 3 | |