wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C Datatypes/Operators 2 MCQs

Total questions: 10

Worksheet time: 20mins

Name
Class
Date
1.

Predict the output

#include <stdio.h>

int main() {

float c = 5.0;

printf ("Temperature in Fahrenheit is %.2f", (9/5)*c + 32);

return 0;

}

a)
Temperature in Fahrenheit is 41.00
b)
Temperature in Fahrenheit is 37.00
c)
Temperature in Fahrenheit is 0.00
d)
Compiler Error
e)
None
2.
#include "stdio.h" int main() { int x, y = 5, z = 5; x = y == z; printf("%d", x); getchar(); return 0; }
a)
0
b)
1
c)
5
d)
Compiler Error
e)
None
3.
#include <stdio.h> int main() { int i = 1, 2, 3; printf("%d", i); return 0; }
a)
1
b)
2
c)
Garbage value
d)
Compile Error
e)
None
4.

#include <stdio.h> int main() { int i ;

i= 1, 2, 3;

printf("%d", i);

return 0; }

a)
1
b)
2
c)
3
d)
4
e)
None
5.
#include <stdio.h> int main() { int i = (1, 2, 3); printf("%d", i); return 0; }
a)
1
b)
2
c)
3
d)
Compiler Error
e)
None
6.

#include <stdio.h> int main() { int i = 5, j = 10, k = 15; printf("%d ", sizeof(k /= i + j)); printf("%d", k); return 0; }

a)
4 1
b)
4 15
c)
2 1
d)
Compiler Error
e)
None
7.
#include <stdio.h> int main() { int a = 1; int b = 1; int c = a || --b; int d = a-- && --b; printf("a = %d, b = %d, c = %d, d = %d", a, b, c, d); return 0; }
a)
a = 0, b = 1, c = 1, d = 0
b)
a = 0, b = 0, c = 1, d = 0
c)
a = 1, b = 1, c = 1, d = 1
d)
a = 0, b = 0, c = 0, d = 0
e)
None
8.
#include <stdio.h> int main() { int a = 10, b = 20, c = 30; if (c > b > a) printf("TRUE"); else printf("FALSE"); return 0; }
a)
Compile time error
b)
True
c)
False
d)
Output is compiler dependent
e)
None
9.
#include <stdio.h> int main() { int i = 12; int j = sizeof(i++); printf("%d %d", i, j); return 0; }
a)
12 4
b)
13 4
c)
13 0
d)
Compiler error
e)
None
10.
#include<stdio.h> int main() { int a = 2,b = 5; a = a^b; b = b^a; printf("%d %d",a,b); return 0; }
a)
5 2
b)
7 7
c)
5 7
d)
7 2
e)
None