Sail E0 Webinar

MCQs

Total Questions : 97 | Page 4 of 10 pages
Question 31. When 2 is entered, The output of the code below is?

    void main()

    {

        int ch;

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

        scanf("%d", &ch);

        switch (ch)

        {

        case 1:

            printf("1\n");

            break;

            printf("Hi");

        default:

            printf("2\n");

        }

    }

  1.    1
  2.    Hi 2
  3.    Run time error
  4.    2
 Discuss Question
Answer: Option D. -> 2


none


Question 32. When 1 is entered, The output of the code below is?

    void main()

    {

        int ch;

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

        scanf("%d", &ch);

        switch (ch, ch + 1)

        {

        case 1:

            printf("1\n");

            break;

        case 2:

            printf("2");

            break;

        }

    }

  1.    1
  2.    2
  3.    3
  4.    Run time error
 Discuss Question
Answer: Option B. -> 2


none


Question 33. What is the output of this C code?

    int main()

    {

        int x = 1;

        if (x > 0)

            printf("inside if\n");

        else if (x > 0)

            printf("inside elseif\n");

    }

  1.    inside if
  2.    inside elseif
  3.    inside if     inside elseif
  4.    Compile time error
 Discuss Question
Answer: Option A. -> inside if


none


Question 34. What is the output of this C code?

    int main()

    {

        int x = 0;

        if (x++)

            printf("true\n");

        else if (x == 1)

            printf("false\n");

    }

  1.    true
  2.    false
  3.    Compile time error
  4.    Undefined behaviour
 Discuss Question
Answer: Option B. -> false


none


Question 35. What is the output of this C code?

    int main()

    {

        int x = 0;

        if (x == 1)

            if (x == 0)

                printf("inside if\n");

            else

                printf("inside else if\n");

        else

            printf("inside else\n");

    }

  1.    inside if
  2.    inside else if
  3.    inside else
  4.    Compile time error
 Discuss Question
Answer: Option C. -> inside else


none


Question 36. Comment on the output of this C code?

    int main()

    {

        int a = 1;

        if (a)

            printf("All is Well ");

            printf("I am Well\n");

        else

            printf("I am not a River\n");

    }

  1.    Output will be All is Well I am Well
  2.    Output will be I am Well I am not a River
  3.    Output will be I am Well
  4.    Compile time errors during compilation
 Discuss Question
Answer: Option D. -> Compile time errors during compilation


none


Question 37. What is the output of this C code?

    int main()

    {

        if (printf("%d", printf(")))

            printf("We are Happy");

        else if (printf("1"))

            printf("We are Sad");

    }

  1.    0We are Happy
  2.    1We are Happy
  3.    1We are Sad
  4.    Compile time error
 Discuss Question
Answer: Option D. -> Compile time error


none


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

    void main()

    {

        double ch;

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

       scanf("%lf", &ch);

        switch (ch)

        {

        case 1:

            printf("1");

            break;

        case 2:

            printf("2");

            break;

        }

    }

  1.    Compile time error
  2.    1
  3.    2
  4.    Varies
 Discuss Question
Answer: Option A. -> Compile time error


none


Question 39. What is the output of this C code(When 1 is entered)?

    void main()

    {

       char *ch;

       printf("enter a value btw 1 to 3:");

        scanf("%s", ch);

       switch (ch)

        {

        case "1":

            printf("1");

            break;

        case "2":

            printf("2");

            break;

        }

    }

  1.    1
  2.    Compile time error
  3.    2
  4.    Run time error
 Discuss Question
Answer: Option B. -> Compile time error


none


Question 40. What is the output of this C code(When 1 is entered)?

    void main()

    {

        int ch;

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

        scanf("%d", &ch);

        switch (ch)

       {

        case 1:

            printf("1\n");

        default:

            printf("2\n");

        }

    }

  1.    1
  2.    2
  3.    1 2
  4.    Run time error
 Discuss Question
Answer: Option C. -> 1 2


none


Latest Videos

Latest Test Papers