ExamVeda
Login
Home
1
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int i = 0;
    if (i == 0)
    {
        goto label;
    }
    label: printf("Hello");
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
2
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int i = 0;
    if (i == 0)
    {
        printf("Hello");
        break;
    }
}
Discuss
Answer & Solution
Answer: Option D
Solution:
The correct answer is D: Compile time error

Here's why:

In C, the `break` statement is used to exit loops (like `for`, `while`, or `do-while`) or `switch` statements.

It's designed to jump out of these control structures.

In this code, `break` is placed directly inside an `if` block, but not within any loop or `switch`.

The C compiler will detect that `break` is used in an invalid context.

Therefore, the program will result in a compile-time error, indicating that the `break` statement is misplaced. The program won't even run.

In summary: The `break` statement is only valid inside loops or `switch` statements.
3
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int x = 0;
    if (x == 0)
        printf("hi");
    else
        printf("how are u");
        printf("hello");
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
4
Which keyword can be used for coming out of recursion?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
5
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int i = 0, k;
    if (i == 0)
        goto label;
        for (k = 0;k < 3; k++)
        {
            printf("hi ");
            label: k = printf("%03d", i);
        }
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
6
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 0, j = 0;
    while (i < 5, j < 10)
    {
        i++;
        j++;
    }
    printf("%d, %d\n", i, j);
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
7
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int x = 5;
    if (true);
        printf("hello");
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
8
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 0, j = 0;
    while (l1: i < 2)
    {
        i++;
        while (j < 3)
        {
            printf("loop\n");
            goto l1;
        }
    }
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
9
What will be the output of the following C code?
#include <stdio.h>
void main()
{
    int i = 0;
    if (i == 0)
    {
        printf("Hello");
        continue;
    }
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
10
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
#include <stdio.h>
void main()
{
    double ch;
    printf("enter a value between 1 to 2:");
    scanf("%lf", &ch);
    switch (ch)
    {
       case 1:
         printf("1");
         break;
       case 2:
         printf("2");
         break;
    }
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board