My Report

C Programming Practice Test 3


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

1. Is initialisation mandatory for local static variables?

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

    #include <stdio.h>
    int main()
    {
        register static int i = 10;
        i = 11;
        printf("%d\n", i);
    } 

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

    #include <stdio.h>
    int main()
    {
        foo();
        foo();
    }
    void foo()
    {
        int i = 11;
        printf("%d ", i);
        static int j = 12;
        j = j + 1;
        printf("%d\n", j);
    } 

4. Automatic variables are allocated space in the form of a __________

5. Which directory the compiler first looks for the file when using #include?

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

    #include <stdio.h>
    int main()
    {
        int one = 1, two = 2;
        #ifdef next
        one = 2;
        two = 1;
        #endif
        printf("%d, %d", one, two);
    }

7. Which of the following names for files not accepted?

8. How is search done in #include and #include “somelibrary.h” according to C standard?

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

10. If storage class is not specified for a local variable, then the default class will be auto.


 

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.