C Programming MCQ Questions and Answers on Conditional Statements 2

Image

Learn C Programming MCQ Questions and Answers on Conditional Statements like Ternary Operator, IF, ELSE and ELSE IF statements. Easily attend exams after reading these Multiple Choice Questions.

Go through C Theory Notes on Conditional Operators before studying questions.



1) What is the output of C Program.?
int main()
{
    int x=1;
    float y = 1.0;
    if(x == y)
    {
        printf("Polo\n");
    }
    if( 1 == 1.0)
    {
        printf("Golf\n");
    }

    if( 1.0 == 1.0f )
    {
         printf("Boxing\n");
    }
    return 0;
}
A) No Output
B) Boxing
C) Golf Boxing
D) Polo Golf Boxing
Answer [=]
Answer[=]
2) What is the output of C Program.?
int main()
{
    int a=9;
    if(a=8)
    {
        printf("Kangaroo\n");
    }
    printf("Eggs\n");

    return 0;
}
A) No output
B) Eggs
C) Kangaroo Eggs
D) Compiler error
Answer [=]
Answer[=]
3) What is the output of C Program.?
int main()
{
    int a=9;
    if(a==5);
    {
        printf("Kangaroo\n");
    }
    printf("Eggs\n");

    return 0;
}
A) Eggs
B) Kangaroo Eggs
C) No output
D) Compiler error
Answer [=]
Answer[=]
4) What is the output of C Program.?
int main()
{
    int a=9;
    if(a==9);
    {
        printf("Ostrich\n");
    }
    elseif(a==8)
    {
        printf("Eggs\n");
    }
    
    printf("White");

    return 0;
}
A) White
B) Ostrich White
C) No Ouput
D) Compiler error
Answer [=]
Answer[=]
5) What is the output of C Program.?
int main()
{
    int a=9;
    if(a==9)
    {
        printf("Ostrich\n");
    }
    else;
    {
        printf("Eggs\n");
    }
    
    printf("White");

    return 0;
}
A) White
B) Ostrich White
C) Ostrich Eggs White
D) Compiler Error
Answer [=]
Answer[=]
6) What is the output of C Program.?
int main()
{
    int a=9, b=5, c=8;
    a=b=c=10;
    if(a==9)
    {
        printf("Ostrich\n");
    }
    else
    {
        printf("Eggs\n");
    }
    
    printf("White");

    return 0;
}
A) Ostrich Eggs White
B) Ostrich White
C) Eggs White
D) Compiler error as you can not assign to more than two variables at once.
Answer [=]
Answer[=]
7) What is the output of C Program.?
int main()
{
    int a=9, b=5, c=8;

    if(!(a==9))
    {
        printf("Bear\n");
    }
    else
    {
        printf("Elephant\n");
    }
    
    printf("Fox");

    return 0;
}
A) Bear Fox
B) Elephant Fox
C) Fox
D) Compiler error
Answer [=]
Answer[=]


 

8) What is the Priority of C Logical Operators.? NOT (!), AND (&&) and OR (||)
A) NOT (!) > AND (&&)  > OR (||)
B) NOT (!) > AND (&&) = OR (||)
C) AND (&&) > OR (||) > NOT (!)
D) AND (&&) = OR (||) > NOT (!)
Answer [=]
Answer[=]
9) What is the output of C Program.?
int main()
{
    int a=9, b;
    
    b = (a==9) ? (printf("CAT\n");printf("DOG\n")) : (printf("FOX"));

    return 0;
}
A) CAT DOG
B) FOX
C) CAT DOG FOX
D) Compiler error
Answer [=]
Answer[=]
10) What is the output of C Program.?
int main()
{
    int a=9, b=6;
    if(a==9 && b==6)
    {
        printf("Hockey");
    }
    else
    {
        printf("Cricket");
    }
    

    return 0;
}
A) Cricket Football
B) Hockey Football
C) Football
D) Compiler error
Answer [=]
Answer[=]
11) What is the output of C Program.?
int main()
{
    int a=9, b=6;
    if(a!=9 || b==6)
    {
        printf("Hockey\n");
    }
    else
    {
        printf("Cricket\n");
    }
    
    printf("Football");

    return 0;
}
A) Cricket Football
B) Hockey Football
C) Football
D) Compiler error
Answer [=]
Answer[=]
12) Choose a correct C Operator Priority.? Items in one group ( ) has same priority.
A) ( ! ) < (*, /, %) < (+, -) < ( <, <=, >, >=) < (==, !=) < (&&) < (||) < (=)
B) (( ! ) , (*, /, %) , (+, -)) < ( <, <=, >, >=) < (==, !=) < (&&) < (||) < (=)
C) ( ! ) > (*, /, %) > (+, -) > ( <, <=, >, >=) > (==, !=) > (&&) > (||) > (=)
D) (( ! ) , (*, /, %) , (+, -)) > ( <, <=, >, >=) > (==, !=) > (&&) > (||) > (=)
Answer [=]
Answer[=]
13) What is the output of C Program.?
int main()
{
    int a=5, b=8;
    
    if( a==5 && (b=9) )
    {
        printf("Gorilla Glass=");
    }
    printf("%d %d", a, b);

    return 0;
}
A) 5 8
B) 5 9
C) Gorilla Glass=5 8
D) Gorilla Glass=5 9
Answer [=]
Answer[=]
14) What is the output of C Program.?
int main()
{
    int a=5, b=8;
    
    if( a==5 || (b=9) )
    {
        printf("Gorilla Glass=");
    }
    printf("%d %d", a, b);

    return 0;
}
A) 5 8
B) 5 9
C) Gorilla Glass=5 8
D) Gorilla Glass=5 9
Answer [=]
Answer[=]


 

15) Choose a correct C Statement.
A) Nesting of ? : operator is possible.
B)
int main()
{
    int a=5, b=8;
    
    if( a>=5 || (b=9) )
    {
        printf("Gorilla Glass");
    }

    return 0;
}
//OUTPUT: Gorilla Glass
C)
int main()
{
    int a=5, b=8;
    
    if( a >= 5 && b <= 9 )
    {
        printf("Gorilla Glass");
    }

    return 0;
}
//OUTPUT: Gorilla Glass
D) All the above
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Some good C Books

Book Price
1. C: The Complete Reference  Check Price
2. Let Us C Check Price
3. Programming in ANSI C Check Price
4. The C Programming Language Check Price

We may get some affiliate commission for the above purchases.