My Report

C Programming Mock Test 2


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. What will be the output of the following C code?

    #include <stdio.h>
    void main()
    {
        int i = 0;
        int j = 0;
        for (i = 0;i < 5; i++)
        {
            for (j = 0;j < 4; j++)
            {
                if (i > 1)
                    continue;
                    printf("Hi \n");
            }
        }
    } 

Question 1 of 10

Question 2 of 10

2. What will be the output of the following C code?

    #include <stdio.h>
    int main()
    {
        int x = 0;
        if (x++)
            printf("true\n");
        else if (x == 1)
            printf("false\n");
    } 

Question 2 of 10

Question 3 of 10

3. What will be the output of the following C code?

    #include <stdio.h>
    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");
    } 

Question 3 of 10

Question 4 of 10

4. What will be the output of the following C code?

    #include <stdio.h>
    void main()
    {
        double b = 5 & 3 && 4 || 5 | 6;
        printf("%lf", b);
    } 

Question 4 of 10

Question 5 of 10

5. What will be the output of the following C code?

    #include <stdio.h>
    int main()
    {
        int x = 3, y = 2;
        int z = x << 1 > 5;
        printf("%d\n", z);
    } 

Question 5 of 10

Question 6 of 10

6. What will be the output of the following C code?

    #include <stdio.h>
    void main()
    {
        int h = 8;
        int b = 4 * 6 + 3 * 4 < 3 ? 4 : 3;
        printf("%d\n", b);
    } 

Question 6 of 10

Question 7 of 10

7. 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;
        }
    } 

Question 7 of 10

Question 8 of 10

8. What will be the output of the following C code?

    #include <stdio.h>
    int main()
    {
        int x = 3, i = 0;
        do {
            x = x++;
            i++;
        } while (i != 3);
        printf("%d\n", x);
    } 

Question 8 of 10

Question 9 of 10

9. What will be the output of the following C code?

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

Question 9 of 10

Question 10 of 10

10. What will be the output of the following C function?

    #include <stdio.h>
    void reverse(int i);
    int main()
    {
        reverse(1);
    }
    void reverse(int i)
    {
        if (i > 5)
            return ;
        printf("%d ", i);
        return reverse((i++, i));
    } 

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.