Signup/Sign In

Decision Making and Looping

This Test will cover the Decision Making and Looping of C Langauge, including if-else statement, switch statement, for loop, while loop etc.
Q. What will be the result of given code?
main()
{
    int i=3;
    switch(i)
    {
        default:printf("zero");
        case 1: printf("one");
        break;
        case 2:printf("two");
        break;
        case 3: printf("three");
        break;
    }
}
Q. What will be the result of given code?
main()
{
    int i = 1;
    for(;;)
    {
        printf("%d",i++);
        if(i > 5)
            break;
    }
}
Q. What will be the result of given code?
main()
{
    int i = 1;
    int j = 2;
    switch(i)
    {
        case 1: printf("one");
        break;
        case j: printf("two");
        break;
    } 
}

Q. What will be the result of given code?
main()
{
    printf(5 + "Good Morning");
}
Q. Can we use string inside switch statement?
Q. What will be the result of given code?
main()
{
    int a =10;
    if(a = 5)
        printf("hello");
    else
        printf("bye");
}
In situations where we need to execute body of the loop before testing the condition, we should use __________.

Q. What will be the result of given code?
main()
{ 
    int i;
    printf("%d", scanf("%d", &i));    // value 10 is given as input here
}
Q. What will be the result of given code?
main()
{
    switch (2)
    {
        case 1: printf("one");
        case 2: printf("two");
        case 3: printf("three");
        default: printf("four");
    }
}
Q. What will be the result of given code?
main()
{
    int a = 0;
    if(a)
        printf("Study");
    else
        printf("tonight");
}

Related Tests: