Here are a few set of, simple but tricky code, just analyze the code and guess the output.
===================================================
1. What is the Output of the below C-Code.?
int main()
{
int i;
for (i = 10 == 0; i <= 10; i++)
{
printf("Hello");
}
}
ANS : 11
===================================================
2. What is the Output of the below C-Code.?
#include <stdio.h>
int main()
{
int x = 2;
switch(x)
{
case 1: printf("A");
break;
case 3: printf("B");
break;
case default: printf("C");
case 4: printf("D");
break;
}
}
ANS : Compiler Error
===================================================
3. What is the Output of the below C-Code.?
int main()
{
int a = 0;
if (a-- <= 0)
printf("TRUE");
else
printf("FALSE");
}
ANS : TRUE
===================================================
4. What is the Output of the below C-Code.?
int main()
{
int a = 355 >> 16;
printf("%d", a);
}
ANS : 0
===================================================
5. What is the Output of the below C-Code.?
int main()
{
int a,b,c,d,e,f,g,h,k;
a=8, b=3, c=2, d=3, e=2, f=11;
printf("%d\n", a-b || (a-b*c) + d && e - f % 3);
}
ANS : 1
===================================================
6. What is the Output of the below C-Code.?
#include <stdio.h>
int main()
{
switch(6)
{
case 6.0f:
printf("Hello");
break;
case 6.0:
printf("World");
break;
case 6.0L:
printf("Infi");
break;
default:
printf("Bytes");
}
}
ANS : Compiler Error
===================================================
7. What is the Output of the below C-Code.?
int red = 10;
if (red == 5)
{
printf ("Hello");
}
else
{
printf ("World");
}
ANS : World
===================================================

No comments:
Post a Comment