1.
The output of the code below is
#include 
    void main()
    {
        int x = 5;
        if (x < 1)
            printf("hello");
        if (x == 5)
            printf("hi");
        else
            printf("no");
    }

Hi

Hello

No

None of the mentioned

2.
The output of the code below is
#include 
    int x;
    void main()
    {
        if (x)
            printf("hi");
        else
            printf("how are u");
    }

Hi

How are you

Compile time error

None of the mentioned

3.
Comment on the following code below
#include 
    void main()
    {
        int x = 5;
        if (true);
            printf("hello");
    }

It will display hello

It will throw an error

Nothing will be displayed

Compiler dependent

6.
The output of the code below is(when 1 is entered)
#include 
    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;
        }
    }

Compile time error

1

2

Varies

7.
The output of the code below is(When 1 is entered)
#include 
    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

2

Compile time error

No Compile time error

8.
When 1 is entered, The output of the code below is?
#include 
    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

2

1 2

Run time error

9.
When 2 is entered, The output of the code below is?
#include 
    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

Hi 2

Run time error

2

10.
When 1 is entered, The output of the code below is?
#include 
    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

2

3

Run time error

11.
What is the output of this C code?
#include 
    int main()
    {
        int x = 1;
        if (x > 0)
            printf("inside if\n");
        else if (x > 0)
            printf("inside elseif\n");
    }

Inside if

Inside elseif

Inside if inside elseif

Compile time error

12.
What is the output of this C code?
#include 
    int main()
    {
        int x = 0;
        if (x++)
            printf("true\n");
        else if (x == 1)
            printf("false\n");
    }

True

False

Compile time error

Undefined behaviour

13.
What is the output of this C code?
#include 
    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");
    }

Inside if

Inside else if

Inside else

Compile time error

14.
What is the output of this C code?
#include 
    int main()
    {
        int x = 0;
        if (x == 0)
            printf("true, ");
        else if (x = 10)
            printf("false, ");
        printf("%d\n", x);
    }

False, 0

True, 0

True, 10

Compile time error

15.
What is the output of this C code?
#include 
    int main()
    {
        int x = 0;
        if (x == 1)
            if (x >= 0)
                printf("true\n");
            else
                printf("false\n");
    }

True

False

Depends on the compiler

No print statement

0Shares
0
Scroll to Top