Worksheetsfirst round quiz
Total questions: 20
Worksheet time: 20mins
1.What is the output of this C code?
#include void main()
{ int x=1,y=0,z=5;
int a=x&&y||z++;
printf("%d",z);
}
6
5
0
varies
2.What is the output of this C code?#include void main()
{ int x=1,z=3;
int y=x<<3;
printf("%d\n",y);
}
-2147483648
Runtime Error
8
-1
3.What will be the output?void main() {
i=0x10+010+10;
printf("\nx=%x",i);
}
I=34
x=22
x=34
error
4.Int i=20;
Printf(“%X”,i);
What is the output?
20
15
14
error
What will be the size of the following union declaration?
Union test {
int x;
char y;
float z;
};
5
4
6
7
What will be the size of the following union declaration?
struct test{
int x;
char y;
float z;
};
4
5
6
7
7.What will be the output of the following C code?
#include int main()
{ int x = 1, y = 2;
int z = x & y == 2;
printf("%d\n", z);
}
0
1
error
depends on complier
8.int main()
{ int a=89;
printf("%c",a);
return 0;
}
89
y
Y
error
9.What will be the output of the following C code?#include void main() {
int x=0;
int ptr=&x;
printf("%d\n",ptr);
}
Address of x
Zero
Junk value
Runtime Error
10.What will be the output of the C code?
#include int main() {
int a=1;
if(a--)
printf("True");
if(a++)
printf("False");
}
true
false
true false
no output
11.what is the output of this
int main(void)
{ int cog;
cog=printf("Hey,Welcome")+printf(" to world");
printf("\n%d characters were printed",cog);
return 0; }
20 characters were printed
Hey,Welcometo world
20 characters were printed
Hey,Welcome to world
20 characters were printed
RunTime Error : Cannot assign string values to integer type.
#include
int a=30;
main(void)
{ a=43;
printf("%d", a);
}
30
43
a
error
13.types of error
syntax
logic
compile
all the above
14.#include
int main() {
int i = 1;
if (i++ && (i == 1))
printf("No\n");
else printf("Yes\n"); }
yes
no
Depends on the compiler
Depends on the standard
15.What will be the final value of J in the following C code?
#include<stdio>
int main() {
int i=10,j=0;
if(I||(J=I+10))
//DO SOMETING ; }
zero
complier error
20
depends on language standard
16.What will be the output of the following C code?
#include <stdio.h>
int main() {
int a=2,b=0;
int y=(b==0)?a:(a>b)?(b=1):a;
printf("%d",y); }
Compile time error
one
two
undefined behavior
17.What will be the output of the following C code? #include <stdio.h>
int main() {
if(7&8) printf("Honest");
if((~7&0*000f)==8)
printf("is the best policy");
}
Honest is the best policy
honest
Is the best policy
No output
18.What will be the output of following C code?
#include int main()
{ int k=8;
int m=7; k
Runtime error
Compiletime error
7
8
19.What will be the output of this?
#include int main() {
int a[]={2,3};
int b[]={4,6};
if(a) { int a=7;
int b=8; printf("%d",a);
} }
7
3
8
6
error
20.What will be the output of the following c code?
int main() {
int x=-2;
x=x>>1;
printf("%d\n",x); }
1
-1
231-1 considering int to be 4 bytes
2
