Explore topic-wise MCQs in C Programming.

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.

1.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int t1 = 8, t2 = 9, t3;
if (t3 = t1 = 4 || t2 > 10)
printf("%d", t3);
else
printf("No Output n");
}

A. 1
B. 9
C. 8
D. 10
E. No output
Answer» B. 9
2.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = -2, q = 5, r = 2, s;
s = ++p && ++q || ++r;
printf("%d, %d, %d, %d n", p, q, r, s);
return 0;
}

A. -1, 6, 2, 1
B. Compilation Error
C. 1, 6, 2, -1
D. 6, 2, 1, -1
E. None of these
Answer» B. Compilation Error
3.

What will be the size of the following C structure?
#include <stdio.h>
struct test
{
int array[10];
char ch;
};

A. 41
B. 44
C. 5
D. 11
E. None of these
Answer» C. 5
4.

What will be the output of the following C code?
#include 
printf("%d", sizeof(strlen("InterviewMania")));

A. Error, sizeof cannot evaluate size of a function
B. Output, 16
C. Output, 4
D. Output, 10
E. None of these
Answer» D. Output, 10
5.

Which among the following is never possible in C when members in a structure are same as that in a union?
//Let P be a structure
//Let Q be a union

A. sizeof(P) is less than to sizeof(Q)
B. sizeof(P) is greater than sizeof(Q)
C. sizeof(P) is equal to sizeof(Q)
D. All of above
E. None of these
Answer» B. sizeof(P) is greater than sizeof(Q)
6.

What will be the output of the following C code?
#include <stdio.h>
//(sizeof double = 10, float = 5, void = 4)
#define PI 3.14
int main()
{
printf("%d", sizeof(PI));
}

A. 1
B. 4
C. 8
D. Compilation Error
E. None of these
Answer» D. Compilation Error
7.

What will be the output of the following C code?
#include <stdio.h>
main()
{
int N = 15;
printf("Size of N is %d, ", sizeof(++N));
printf("Value of N is %d", N);
};

A. Size of N is 4, Value of N is 15
B. Compilation Error
C. Garbage value
D. Size of N is 15, Value of N is 4
E. None of these
Answer» B. Compilation Error
8.

Which among the following is never possible in C when members are different in a structure and union?
//Let P be a structure
//Let Q be a union

A. sizeof(P) is equal to sizeof(Q)
B. sizeof(P) is greater than sizeof(Q)
C. sizeof(P) is less than sizeof(Q)
D. All of above
E. None of these
Answer» F.
9.

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;
printf ("a = %d b = %d c = %d n", ++a, b++, ++c);
return 0;
}

A. a = 2 b = 1 c = 2
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
10.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num = 4, k = 1;
do {
num = num++;
k++;
} while (k != 4);
printf("%d n", num);
}

A. 1
B. Undefined behaviour
C. 2
D. 3
E. 4
Answer» F.
11.

What will be the output of the following C code?
#include <stdio.h>
union test
{
char ch;
char c;
int n;
}ts;
int main()
{
printf("%d", sizeof(ts));
return 0;
}

A. 6
B. 4
C. 2
D. 1
E. None of these
Answer» C. 2
12.

What will be the output of the following C code?
#include 
printf("%d", sizeof('n'));

A. 4
B. 2
C. 1
D. All of above
E. None of these
Answer» B. 2
13.

Size of an array can be evaluated by __________.
(Assuming array declaration int array[25];)

A. 10 * sizeof(array);
B. sizeof(array[10]);
C. sizeof(*array);
D. sizeof(array);
E. None of these
Answer» E. None of these
14.

Which of the following statements are correct about the program given below?
#include <stdio.h>
int main ( )
{
float x = 2.8, y = 2.88;
if (x = y)
printf ("x and y are equal n");
else
printf ("x and y are not equal n");
return 0;
}

A. The output of the program would be "x and y are equal".
B. The statement if (x = y) would report a compilation error.
C. Floats cannot be compared using if.
D. should be used to compare
E. Conditional operates should be used to compare floats.
Answer» B. The statement if (x = y) would report a compilation error.
15.

Which of the following is correct order of evaluation for the expression given below ?

c = a + b * c / 4 % 2 -1;

A. * / % + - =
B. = * / % + -
C. / * % - + =
D. * / % - + =
E. - % / * + =
Answer» B. = * / % + -
16.

Which function in the following expression will be called first?
num = functionC(8) - functionB(5, 6) / functionA(2, 3, 4);

A. functionA();
B. functionC();
C. Cannot be predicted
D. functionB();
E. None of these
Answer» D. functionB();
17.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 3, q = 2;
int R = (q++) ? q == 1 && p : 1;
printf("%d n", R);
return 0;
}

A. 0
B. 1
C. 2
D. 3
E. None of these
Answer» B. 1
18.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 3, q = 4;
p += q -= p;
printf("%d %d", p, q);
}

A. 3
B. 4
C. 3 4
D. 4 1
E. None of these
Answer» E. None of these
19.

What will be the final value of c in the following s statement? (Initial value: s = 2)
s <<= 1;

A. s = 4;
B. s = 1;
C. s = 2;
D. s = 3;
E. None of these
Answer» B. s = 1;
20.

What will be the output of the following C code?
 #include <stdio.h>
void main()
{
int L = 6;
int a = 5;
int b = L < a ? L++ : a++;
printf("%d", b);
}

A. Compilation Error
B. 5
C. 6
D. Runtime Error
E. None of these
Answer» C. 6
21.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 6, num, k, R = 0;
scanf("%d", num);
for (k = 0; k < num; k++)
R += p;
}

A. Multiplication of p and num
B. Division of p and num
C. Addition of p and num
D. Subtraction of p and num
E. It will not print any output.
Answer» F.
22.

What will be the final values of p and q in the following C statement? (Initial values: p = 2, q = 1)
q = (q) ? p = 0 : 2;

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
23.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 2;
short int k = 3;
float var = 4;
if (sizeof((p == 3) ? var : k) == sizeof(float))
{
printf("Float n");
}
else if (sizeof((p == 3) ? var : k) == sizeof(short int))
{
printf("Short int n");
}
}

A. Compilation Error
B. Runtime Error
C. Float
D. Short int
E. None of these
Answer» D. Short int
24.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int q = 2, p = 1;
int k = (q++, p++) ? q : p;
printf("%d n", k);
}

A. 0
B. 1
C. 2
D. 3
E. None of these
Answer» E. None of these
25.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 4;
int q = p == 3 ? getchar(): 3;
printf("%d n", q);
}

A. Compilation Error
B. 4
C. 3
D. Whatever character getchar function returns
E. Ascii value of character getchar function returns
Answer» F.
26.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 4;
int q = 1;
int R = (q == 1) ? p :(p > q) ? (q = 1): p;
printf("%d n", q);
}

A. 0
B. 1
C. 4
D. Compilation Error
E. None of these
Answer» C. 4
27.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
int n1 = 15;
int n2 = 16;
n1 < n2 ? n1 = n1 + 1 : n2 = n2 + 1;
printf("%d", n1);
}

A. 15
B. 16
C. Compilation Error
D. Runtime Error
E. None of these
Answer» D. Runtime Error
28.

Which of the following is the correct order of evaluation for the given expression?
calc = s % p / q * R;

A. * % / =
B. = % * /
C. / * % =
D. % / * =
E. None of these
Answer» E. None of these
29.

What will be the output of the following C code?
 #include <stdio.h>
int main()
{
int p1 = 3, p2 = 5;
int p3 = p1 & p2 == 4;
printf("%d n", p3);
}

A. Undefined behaviour
B. 0
C. 1
D. 2
E. Compilation Error
Answer» C. 1
30.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
int num1 = 10;
int num2 = 11;
num1 < num2 ? num1++ : num2 = num1;
printf("%d", num1);
}

A. 10
B. 11
C. Runtime Error
D. Compilation Error
E. None of these
Answer» E. None of these
31.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int s1 = 5; //, s2 = 9;
const int *ptr = &s1;
*ptr++;
printf("%d n", *ptr);
}

A. 9
B. 5
C. Garbage value
D. Compilation Error
E. Increment of read-only location compile error
Answer» D. Compilation Error
32.

What will be the output of the following C code?
 #include <stdio.h>
int main()
{
int s1 = 5, s2 = 4;
int s3 = s1 << 2 > 6;
printf("%d n", s3);
}

A. Compilation Error
B. 0
C. 1
D. 2
E. Runtime Error
Answer» D. 2
33.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p1 = 3, p2 = 2;
int p3 = p1 /= p2 %= 2;
printf("%d n", p3);
}

A. Compilation Error
B. 3
C. 2
D. 1
E. Floating point exception
Answer» F.
34.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int n1 = 3, n2 = 4;
if (n1 && n2 == 1)
printf("Right n");
else
printf("Wrong n");
}

A. Compilation Error
B. Wrong
C. Runtime Error
D. Right
E. None of these
Answer» C. Runtime Error
35.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num1 = 4, num2 = 2;
int num3 = num2 && (num2 |= 20);
printf("%d n", num3);
return 0;
}

A. 1
B. 2
C. 4
D. 20
E. None of these
Answer» B. 2
36.

What will be the final values of p and q in the following C code?
 #include <stdio.h>
int n = 0;
int main()
{
int p = (funA() + funB()) | funB(); //bitwise or
int q = funB() | (funA() + funB()); //bitwise or
}
int funA()
{
if (n == 0)
return n + 1;
else
return n - 1;
}
int funB()
{
return n++;
}

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
37.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 4, q = 4;
float var = q + p /= p / q;
printf("%d %f n", p, var);
return 0;
}

A. 5 5.000000
B. 5.000000 5
C. Compilation Error
D. 4
E. None of these
Answer» D. 4
38.

What will be the final values of k and L in the following C code?
#include <stdio.h>
int n = 0;
int main()
{
int k = (fun1() + fun2()) | fun2(); //bitwise or
int L = fun2() | (fun1() + fun2()); //bitwise or
}
int fun1()
{
if (n == 0)
return n + 1;
else
return n - 1;
}
int fun2()
{
return n++;
}

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
39.

What will be the output of the following C function?
#include <stdio.h>
void fun(int k);
int main()
{
fun(2);
}
void fun(int k)
{
if (k > 7)
return ;
printf("%d ", k);
return fun((k++, k));
}

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
40.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p1 = 7, p2 = 5, k;
int p3;
p3 = p2 = 3, k = p1 && p2;
printf("%d n", k);
return 0;
}

A. Compilation Error
B. 7
C. Undefined behaviour due to order of evaluation can be different
D. 5
E. 1
Answer» F.
41.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p1 = 10, p2 = 8;
int p3;
p3 = (p2++, p2);
printf("%d n", p3);
return 0;
}

A. 9
B. 8
C. 10
D. Compilation Error
E. Undefined behaviour
Answer» B. 8
42.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int n1 = 5, n2 = 3;
int n3 = (n2++) ? 2 : n2 == 1 && n1;
printf("%d n", n3);
return 0;
}

A. 1
B. 2
C. 3
D. 4
E. 5
Answer» C. 3
43.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 5;
int q = p +(p = 20);
printf("%d n", q);
}

A. 40
B. Compilation Error
C. 20
D. 5
E. None of these
Answer» B. Compilation Error
44.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
double var = 4 % 0 * 1 - 6 / 3;
printf("%lf", var);
}

A. -3
B. Compilation Error
C. -2
D. Floating point Exception
E. None of these
Answer» E. None of these
45.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
double var = 10;
var++;
printf("%lf", var);
}

A. compilation Error
B. 10
C. 10.000000
D. 11
E. 11.000000
Answer» F.
46.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
int t2 = 8;
int t3 = 9;
int t1 = ++t2 + t3--;
printf("%d", t1);
}

A. 8
B. Compilation Error
C. 9
D. 18
E. Runtime Error
Answer» E. Runtime Error
47.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
int n1 = 23;
int n2 = n1++ + n1++ + n1++;
printf("%d n", n1);
}

A. Compilation Error
B. 23
C. Runtime Error
D. 26
E. None of these
Answer» E. None of these
48.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
int p1 = 12;
int p2 = (p1++, p1++);
printf("%d %d n", p2, p1);
}

A. 12 13
B. 13 14
C. 14 15
D. Compilation Error
E. None of these
Answer» C. 14 15
49.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
int t = 15 + 17 * 14 - 19 * (13, 12);
printf("%d", t);
}

A. 12
B. 22
C. 13
D. 23
E. 25
Answer» F.
50.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
int p = 11, q = 12, r = 13, s = 14, t;
t = r + s = q * p;
printf("%d, %d n", t, s);
}

A. 11
B. 12
C. 13
D. 14
E. Syntax error
Answer» F.