WorksheetsC-technical Quiz 1
Total questions: 15
Worksheet time: 16mins
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 1, y = 0, z = 3;
x > y ? printf("%d", z) : return z;
}
3
1
Compile time error
Runtime error
What will be the output of the following C code?
#include <stdio.h>
int main()
{
signed char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}
128
-128
Depends on the compiler
None
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 1, z = 3;
int y = x << 3;
printf(" %d\n", y);
}
-2147483648
-1
Run time error
8
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 2, y = 2;
float f = y + x /= x / y;
printf("%d %f\n", x, f);
return 0;
}
2 4.000000
Compile time error
2 3.500000
Undefined behaviour
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 3; //, y = 2;
const int *p = &x;
*p++;
printf("%d\n", *p);
}
Increment of read-only location compile error
Some garbage value
4
Undefined behaviour
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = -1, b = 4, c = 1, d;
d = ++a && ++b || ++c;
printf("%d, %d, %d, %d\n", a, b, c, d);
return 0;
}
0, 4, 2, 1
0, 5, 2, 1
-1, 4, 1, 1
0, 5, 1, 0
What will be the output of the following C code? (Initial values: x= 7, y = 8)
#include <stdio.h>
void main()
{
float x;
int y;
printf("enter two numbers \n");
scanf("%f %f", &x, &y);
printf("%f, %d", x, y);
}
7.000000, 7
Run time error
7.000000, junk
Varies
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int i = 0;
int j = 0;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
continue;
printf("Hi \n");
}
}
}
Hi is printed 9 times
Hi is printed 8 times
Hi is printed 7 times
Hi is printed 6 times
The C statement “”if (a == 1 || b == 2) {}”” can be re-written as ___________
if (a == 1) if (b == 2){}
if (a == 1){} if (b == 2){}
if (a == 1){} else if (b == 2){}
none of the mentioned
Which of the following option is the correct representation of the following C statement?
e = a b + c / d f;
e = (a (b +(c /(d f))));
e = ((a b) + (c / (d f)));
e = ((a b) + ((c / d) f));
Both e = ((a b) + (c / (d f))); and e = ((a b) + ((c / d) f));
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int h = 8;
int b = h++ + h++ + h++;
printf("%d\n", h);
}
9
10
12
11
What will be the output of the following C code?
#include <stdio.h>
void main()
{
char a = 'A';
char b = 'B';
int c = a + b % 3 - 3 * 2;
printf("%d\n", c);
}
65
58
64
59
Operation “a = a * b + a” can also be written as ___________
a *= b + 1;
(c = a * b)!=(a = c + a);
a = (b + 1)* a;
all
What will be the output of the following C code?
#include <stdio.h>
void main()
{
double x = 123828749.66;
int y = x;
printf("%d\n", y);
printf("%lf\n", y);
}
0, 0.0
123828749, 123828749.66
12382874, 12382874.0
123828749, 0.000000
What will be the output of the following C code?
#include <stdio.h>
int main()
{
unsigned int i = 23;
signed char c = -23;
if (i > c)
printf("Yes\n");
else if (i < c)
printf("No\n");
}
Yes
No
Depends on the compiler
Depends on the operating system
