Header Ads

Easy C Quiz

Here are a few set of, simple but tricky code, just analyze the code and guess the output.

01. What is the Output of the below C-Code.?
int main()
{
    int i;
    for (i = 10 == 0; i <= 10; i++)
    {
        printf("Hello");
    }
}
ANS : 11

02. What is the Output of the below C-Code.?
#include 
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

03. What is the Output of the below C-Code.?
int main()
{
    int a = 0;
     if (a-- <= 0)
                printf("TRUE");
     else
                printf("FALSE");
}
ANS : TRUE

04. What is the Output of the below C-Code.?
int main()

{
    int a = 355 >> 16;
    printf("%d", a);
}
ANS : 0

05. 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

06. What is the Output of the below C-Code.?
#include 
int main()
{
    switch(6)
    {
        case 6.0f:   
        printf("Hello");
                break;
        case 6.0:    
        printf("World");
                break;
        case 6.0L:   
        printf("Cipher");
                break;
        default:     
        printf("onics");
    } 
} 
ANS : Compiler Error

07. What is the Output of the below C-Code.?
int red = 10;
         if (red == 5)
         {
                 printf ("Hello");
         }
         else
         {
                 printf ("World");
         } 
ANS : World 

Pages : 2, 3

No comments