wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SASI -BATCH 3-DAY2-FN

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.
#include <stdio.h> int main() { int x = 1; short int i = 2; float f = 3; if (sizeof((x == 2) ? f : i) == sizeof(float)) printf("float\n"); else if (sizeof((x == 2) ? f : i) == sizeof(short int)) printf("short int\n"); }
a)
float
b)
short int
c)
Undefined behaviour
d)
Compile time error
2.
#include <stdio.h> void main() { int k = 8; int m = 7; int z = k < m ? k++ : m++; printf("%d", z); }
a)
7
b)
8
c)
Run time error
d)
15
3.
#include <stdio.h> void main() { 1 < 2 ? return 1 : return 2; }
a)
returns 1
b)
returns 2
c)
varies
d)
Compile time error
4.
#include <stdio.h> int main() { int num = 7; if (num % 2 == 0) { printf("Even\n"); } else { printf("Odd\n"); } return 0; }
a)
even
b)
odd
c)
neither even nor odd
d)
error
5.
#include <stdio.h> int main() { int a = 10; double b = 5.6; int c; c = a + b; printf("%d", c); }
a)
15
b)
16
c)
15.6
d)
10
6.
#include <stdio.h> int main() { int a = 10, b = 5, c = 5; int d; d = a == (b + c); printf("%d", d); }
a)
Syntax error
b)
1
c)
10
d)
5
7.
(x = foo()) != 1 considering foo() returns 2
a)
2
b)
True
c)
1
8.
Operation “a = a * b + a” can also be written as ___________
a)
a *= b + 1;
b)
(c = a * b)!=(a = c + a);
c)
a = (b + 1)* a;
d)
All of the mentioned
9.
What will be the final value of c in the following C code snippet? (Initial values: a = 1, b = 2, c = 1) c += (-c) ? a : b;
a)
Syntax error
b)
c = 1
c)
c = 2
d)
c = 3
10.
#include <stdio.h> int main() { int a = 10, b = 5, c = 3; b != !a; c = !!a; printf("%d\t%d", b, c); }
a)
5 1
b)
0 3
c)
5 3
d)
1 1
11.
#include <stdio.h> int main() { int a = 10; if (a == a--) printf("TRUE 1\t"); a = 10; if (a == --a) printf("TRUE 2\t"); }
a)
TRUE 1
b)
TRUE 2
c)
TRUE 1 TRUE 2
d)
Compiler Dependent
12.
Which of the following is not an arithmetic operation?
a)
a * = 10;
b)
a / = 10;
c)
a ! = 10;
d)
a % = 10;
13.
#include <stdio.h> int main() { int a = 2; int b = 0; int y = (b == 0) ? a :(a > b) ? (b = 1): a; printf("%d\n", y); }
a)
compile error
b)
1
c)
2
d)
Undefined behaviour
14.
What is short int in C programming?
a)
The basic data type of C
b)
Qualifier
c)
Short is the qualifier and int is the basic data type
d)
All of the mentioned
15.
#include <stdio.h> int main() { int y = 1; if (y & (y = 2)) printf("true %d\n", y); else printf("false %d\n", y); }
a)
true 2
b)
false 2
c)
either true 2 or false 2
d)
true 1