placeholder image to represent content

Condition & Control Structure in C language Quiz

Quiz by ibrahim shabbir (SGA)

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
30 questions
Show answers
  • Q1

    What is the syntax of if-else statement in C programming language?

    if(test-condition) {

              statements

    }

    else {

            statements 

    }

    if-else (test condition) {

            statements 

    }

    else {

           statement 

    }

    if test-condition {

              statements 

    }

    else {

              statement 

    }

    (test-condition) if {

              statements 

    }

    else {

             statement 

    }

    60s
  • Q2

    What is the output of the following?

    #include <stdio.h>

    int main()

    {

     int m=40,n=20;

     if (m>n) {

      printf("m is greater than n");}

     else if(m<n) {

     printf("m is less than n"); }

     else {

      printf("m is equal to n");}

    }

    m is less than n

    compilation error

    m is equal to n

    m is greater than n

    60s
  • Q3

    Can an else statement exist without an if statement preceding it?

    Yes, an else statement can exist without an if statement if its the first line inside the main ().

    Yes, else statement can exist without an if statement.

    Else cannot exist without an if statement, but an else-if statement can exist without a preceding if statement.

    No, an else statement can only exist with an if statement.

    60s
  • Q4

    What is the other name for C Language ?: Question Mark Colon Operator.?

    If-Else Operator

    Ternary Operator

    Comparison Operator

    Binary Operator

    60s
  • Q5

    Choose a syntax for C Ternary Operator from the list.

    condition ? expression1 : expression2

    condition ? expression1 < expression2

    condition < expression1 ? expression2

    condition : expression1 ? expression2

    60s
  • Q6

    Choose a statement to use C If Else statement.

    None

    else or else if is optional with if statement.

    else is compulsory to use with if statement.

    else if is compulsory to use with if statement.

    60s
  • Q7

    What is the output of the C Program.?

    int main(){

    if( 4 > 5 ) {

          printf("Hurray..\n");

    }

    printf("Yes");

    return 0;

    }

    No Output

    Hurray..Yes

    Hurray..

    Yes

    Yes

    60s
  • Q8

    What is the output of the C Program.?

    int main()

    {

    if( 4 < 5 )

             printf("Hurray..\n");

             printf("Yes");

    else

             printf("England")

    return 0;

    }

    England

    Hurray.. Yes

    Yes

    Compilation Error

    60s
  • Q9

    What is the output of C Program.?

    int main()

    {

    if( 10 > 9 )

           printf("Singapore\n");

    else if(4%2 == 0)

          printf("England\n");

          printf("Poland");

    return 0;

    }

    Singapore

    England

    Poland

    England

    Poland

    Singapore

    Singapore

    Poland

    60s
  • Q10

    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;

    }

    Boxing

    Polo

    Golf

    Boxing

    No Output

    Golf

    Boxing

    60s
  • Q11

    Within a switch statement?

    Continue cannot be used but Break can be used

    Neither Continue nor Break can be used

    Continue can be used but Break cannot be used

    Both Continue and Break can be used

    60s
  • Q12

     What will be the output of the given C program?

    #include<stdio.h>

    int main(){

       int a = 2;

       switch(a)

       {

          case 1:

                   printf("Welcome");

                   break;

          case 2:

                  printf("Know Program");

                  break;

          default:

                 printf("Hello");

                 break;

        }

    return 0;

    }

    Compile Time error

    Know Program

    Hello

    Welcome

    60s
  • Q13

    Which of the following cannot be checked in a switch-case statement?

    character

    integer

    decimal

    float

    60s
  • Q14

    What is the output of this C code (when 1 is entered)?

    #include <stdio.h>

    void main(void)

    {

        double ch;

        printf("enter a value between 1 and 2:");

        scanf("%f" , &ch);

        switch(ch)

        {

         case 1:

            printf("1");

            break;

        case 2:

            printf("2");

            break;

        }

    }

    Varies

    Compile time error

    1

    2

    60s
  • Q15

    What will be the output of the following C code? Assuming that we have entered the value 2 in the standard input)

    #include <stdio.h>

    void main()

    {

        int ch;

        printf("enter a value between 1 to 2:");

        scanf ("%d" , &ch);

        switch (ch)

        {

            case 1: printf("1\n");

                             break;

                             printf("Hi");

            default: printf("2\n");

        }

    }

    1

    Hi 2

    2

    Run time error

    60s

Teachers give this quiz to your class