My Report

C Variables Test – 1


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. What will be the output of the following C code?

    #include <stdio.h>
    int *i;
    int main()
    {
        if (i == 0)
            printf("true\n");
        return 0;
    } 

2. Which part of the program address space is p stored in the following C code?

    #include <stdio.h>
    int *p = NULL;
    int main()
    {
        int i = 0;
        p = &i;
        return 0;
    } 

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

    #include <stdio.h>
    static int x = 5;
    void main()
    {
        x = 9;
        {
            int x = 4;
        }
        printf("%d", x);
    } 

4. Can variable i be accessed by functions in another source file?

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

5. Property of the external variable to be accessed by any source file is called by the C90 standard as __________

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

    #include <stdio.h>
    double i;
    int main()
    {
       printf("%g\n",i);
       return 0;
    } 

7. Which part of the program address space is p stored in the following C code?

    #include <stdio.h>
    int *p;
    int main()
    {
        int i = 0;
        p = &i;
        return 0;
    } 

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

    #include <stdio.h>
    int *i;
    int main()
    {
        if (i == NULL)
            printf("true\n");
        return 0;
    } 

 

Start practicing “1000 MCQs on C”, and once you are ready, you can take tests on all topics by attempting our “C Test Series”.

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.