ExamVeda
Login
Home
21
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 0, j = 0;
    while (i < 2)
    {
        l1: i++;
        while (j < 3)
        {
            printf("loop\n");
            goto l1;
        }
    }
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
22
What will be the correct syntax for running two variable for loop simultaneously?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
23
Which for loop has range of similar indexes of 'i' used in for (i = 0;i < n; i++)?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
24
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    do
        printf("In while loop ");
    while (0);
        printf("After loop\n");
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
25
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");
    }
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
26
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    switch (printf("Do"))
    {
       case 1:
          printf("First\n");
          break;
       case 2:
          printf("Second\n");
          break;
       default:
          printf("Default\n");
          break;
    }
}
Discuss
Answer & Solution
Answer: Option C
Solution:
In this code, the switch statement is evaluating the result of the printf("Do") function call. The printf() function returns the number of characters printed.

When printf("Do") is executed, it prints "Do" to the standard output and returns the number of characters printed, which is 2.

So, the switch statement evaluates the value 2.

Since there is a case 2 in the switch statement, it will execute the corresponding code block, which prints "Second" to the standard output.

Therefore, the correct output of the code will be DoSecond. So, the correct answer is Option C: DoSecond.
27
Which datatype can accept the switch statement?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
28
Which loop is most suitable to first perform the operation and then test the condition?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
29
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int k = 0;
    for (k)
        printf("Hello");
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
30
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    while ()
        printf("In while loop ");
    printf("After loop\n");
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board