Sail E0 Webinar

MCQs

Total Questions : 97 | Page 1 of 10 pages
Question 1. What is the output of this C code?

    int main()

    {

        int i = 0, j = 0;

        while (l1: i < 2)

        {

            i++;

            while (j < 3)

            {

                printf("loop\n");

                goto l1;

           }

        }

   }

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


none


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

    int main()

    {

        int i = 0, j = 0;

        l1: while (i < 2)

            {

                i++;

                while (j < 3)

                {

                    printf("loop\n");

                    goto l1;

                }

            }

   }

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


none


Question 3. The output of the code below is?

    int x;

    void main()

    {

        if (x)

            printf("hi");

        else

            printf("how are u");

    }

  1.    hi
  2.    how are you
  3.    Compile time error
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> how are you


none


Question 4. The output of the code below is?

    void main()

    {

        int x = 5;

        if (x < 1)

            printf("hello");

        if (x == 5)

            printf("hi");

        else

            printf("no");

    }

  1.    hi
  2.    hello
  3.    no
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> hi


none


Question 5. Comment on the following code below?

    void main()

    {

       int x = 5;

        if (true);

            printf("hello");

    }

  1.    It will display hello
  2.    It will throw an error
  3.    Nothing will be displayed
  4.    Compiler dependent
 Discuss Question
Answer: Option B. -> It will throw an error


none


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

    int main()

    {

        int x = 0;

        if (x == 0)

           printf("true, ");

        else if (x = 10)

            printf("false, ");

        printf("%d\n", x);

    }

  1.    false, 0
  2.    true, 0
  3.    true, 10
  4.    Compile time error
 Discuss Question
Answer: Option B. -> true, 0


none


Question 7. Which of the following is an invalid if-else statement?
  1.    if (if (a == 1)){}
  2.    if (func1 (a)){}
  3.    if (a){}
  4.    if ((char) a){}
 Discuss Question
Answer: Option A. -> if (if (a == 1)){}


none


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

    int main()

    {

        int a = 1;

        if (a--)

            printf("True");

            if (a++)

                printf("False");

    }

  1.    True
  2.    False
  3.    True False
  4.    No Output
 Discuss Question
Answer: Option A. -> True


none


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

    int main()

    {

        int x = 0;

        if (x == 1)

            if (x >= 0)

                printf("true\n");

            else

                printf("false\n");

    }

  1.    true
  2.    false
  3.    Depends on the compiler
  4.    No print statement
 Discuss Question
Answer: Option D. -> No print statement


none


Question 10. if (a == 1||b == 2){} can be written as:
  1.    if (a == 1)     if (b == 2){}
  2.    if (a == 1){}     if (b == 2){}
  3.    if (a == 1){}     else if (b == 2){}
  4.    None of the mentioned
 Discuss Question
Answer: Option D. -> None of the mentioned


none


Latest Videos

Latest Test Papers