NEW
Font size
WorksheetsCB - CD
Total questions: 20
Worksheet time: 8mins
Which of the following function calculates square of 'x' in c?
sqr(x)
pow(2,x)
power(x,2)
pow(x,2)
How will you print \n on the screen?
printf("\n");
printf("\\n");
printf('\n');
printf("\n\");
What will be the output of the following C code?
hello
no
hi
error
What will be the output of the following C code?
hi
how are u
hello
hihello
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
1 2
1
2
error
What will be the output of the following C code?
yes
yes default
default
error
Which of the following is not a valid C variable name?
int number;
float rate;
int $main;
int variable_count;
Which keyword is used to prevent any changes in the variable within a C program?
immutable
const
mutable
volatile
What is the output of this code?
int a = 5, b = 2;
printf("%d", a / b);
2.5
2.0
2
0
Which symbol is used to write a single-line comment in C?
/* comment */
# comment
// comment
-- comment
Which operator is used to assign a value to a variable?
==
=
:=
<-
What will be the output of the following code?
int a = 5, b = 2;
printf("%d", a + b * a);
35
15
20
25
What will be the value of x after this operation?
int x = 10;
x %= 3;
3
1
0
10
Which of the following performs a bitwise AND operation?
&
&&
and
|
What will be printed?
int x = 5;
printf("%d", x > 2 ? x < 10 ? 100 : 200 : 300);
100
200
300
10
What is the result of this expression?
int x = 3;
printf("%d", x = x == 3);
3
1
0
Error
Guess the output:
int a = 2, b = 5;
printf("%d", a++ * ++b);
10
12
15
Undefined
Output of this?
int x = 5;
if (x++ == 5)
printf("%d", x);
else
printf("%d", x + 1);
5
6
7
4
Guess the output:
int a = 1, b = 2;
switch (a) {
case 1:
switch (b) {
case 1: printf("X"); break;
case 2: printf("Y"); break;
}
case 2: printf("Z");
}
XZ
Y
X
YZ
int x = 1;
switch (x * 2) {
case 1+1: printf("A"); break;
case 2+2: printf("B"); break;
default: printf("C");
}
A
B
C
ERROR
