Sunday 18 July 2010

Interview Questions on Control Flow Statements

What is the output

#include <stdio.h>
    void main()
    {
        int a = 5;
        if (a < 1)
            printf("Kezriwal");
        if (a == 5)
            printf("MoDi");
        else
            printf("Vajpayee");
    }
a) MoDi
b) Kezriwal
c) Vajpayee
d) None of the mentioned

Answer:a

What is the output

    #include <stdio.h>
    int a;
    void main()
    {
        if (a)
            printf("Namasthe");
        else
            printf("Bharath");
    }
a) Namasthe
b) Bharath
c) Compile time error
d) None of the mentioned

Answer:b

What is the output

    #include <stdio.h>
    void main()
    {
        int a = 10;
        if (true);
            printf("Kalam");
    }
a) Kalam
b) Error
c) No Output
d) Compiler dependent

Answer:b

What is the output

    #include <stdio.h>
    void main()
    {
        int x = 0;
        if (x == 0)
            printf("Swatch");
        else
            printf("Bharath");
            printf("India");
    }

a) Swatch
b) Bharath
c) hello
d) SwatchIndia

Answer:d

What is the output

    #include <stdio.h>
    void main()
    {
        int x = 5;
        if (x < 1);
            printf("Hello");

    }
a) Nothing
b) Run time error
c) Hello
d) Varies

Answer:c

Back
Next: Interview Questions on if else


No comments:

Post a Comment