WorksheetsC Code Master
Total questions: 20
Worksheet time: 10mins
What will the result of num1 variable after execution of the following statements?
int j = 1, num1 = 4;
while (++j <= 10)
{
num1++;
}
11
12
13
14
What is the output of the following
printf("%d",34+24/12%3*5/2-4);
35
34
32
37
c = (n) ? a : b; can be rewritten as
exp1 ? exp2 : exp3;
if(n){c = a;}else{c = b;}
if(!n){c = a;}else{c = b;}
if(n){c = b;}else{c = a;}
None of the above
What is the output of the following code.
void main()
{
int i = 0;
if (i == 0)
{
printf("Hello");
break;
}
}
Hello is printed infinite times
Hello
compile time error
varies
Point out the wrong statement about malloc.
Allocated memory has undefined value
Pointer is NULL if memory is not allcoated
It returns pointer to the allocated space
It doesn't lead to memory leak if memory is not de allocated
What is the result after execution of the following code if a is 10, b is 5, and c is 10?
if ((a > b) && (a <= c))
a = a + 1;
else
c = c+1;
a = 10, c = 10
a = 11, c = 10
a = 11, c = 11
a = 10, c = 11
What is the output of this code?
char ch;
ch=A;
printf(“%c”,ch);
Compile time error
A
65
garbage value
Which of the following is an invalid assignment operator?
A%=10;
A/=10;
A|=10
none
What is the output of this C code?
int main()
{
int a = 2;
int b = 0;
int y = (b == 0) ? a :(a > b) ? (b = 1): a;
printf("%d\n", y);
}
1
2
Compile time error
Undifined
Comment on the output of this C code?
int main()
{
int a[5] = {1, 2, 3, 4, 5};
int i;
for (i = 0; i < 5; i++)
if ((char)a[i] == '5')
printf("%d\n", a[i]);
else
printf("FAIL\n");
}
Program will compile and print the output 5
Error will generate
print the ASCII value of 5
print FAIL for 5 times
What following operator is called
?:
Scope resolution
operation
condition
operation
ternary operation
loop operation
What is the output of the below program?
int main()
{
for(; ;)
for(; ;)
printf("Hello..");
return 0;
}
Hello..
Runtime Error
Hello.. is printed two time
Hello.. is printed infinite times
How would you round off a value from 1.66 to 2.0?
ceil(1.66)
floor(1.66)
roundto(1.66)
roundup(1.66)
What is the output of the program given below ?
1, 2, 3
2, 1, 0
1, 0, 2
0, 2, 1
What will be the output of the following C code?
8 3
3 8
5 3
8 5
What is the use of rewind() function in C?
gives current position in the file
set the position to the beginning point
set the position to desire point
None of these
What is the result on the console screen?
1 1
2 2
compile time error
runtime error
What will be the final value of the c in the following c statement.
int c=2;
c<<=1;
printf("%d",c);
1
3
4
0
What will be the output of the following C code?
#include <stdio.h>
int main()
{
while ()
printf("In while loop ");
printf("After loop\n");
}
In while loop after loop
After loop
Compile time error
Infinite loop
What will be the output of following code.
#include "stdio.h"
int main()
{
int x = 50;
int y = 60;
printf("%d %d", x++, y--);
printf("#%d %d", ++x, --y);
return 0;
}
50 59#51 59
50 60#51 59
51 59#52 58
50 60#52 58
