Thursday 9 November 2017

Variables Questions in C

------------------------------------------------------------------------------------------------------------
Previous Page                Home                  Last Page
------------------------------------------------------------------------------------------------------------

6.
What is the output of this C code?

    #include
    int x = 5;
    void main()
    {
        int x = 3;
        m();
        printf("%d", x);
    }
    void m()
    {
        x = 8;
        n();
    }
    void n()
    {
        printf("%d", x);
    }

A. 8 3
B. 3 8
C. 8 5
D. 5 3

Answer: A
--------------------------------------------------------------------------------------------------------------------

7.
Find the output?

#include
    int x;
    void main()
    {
        m();
        printf("%d", x);
    }
    void m()
    {
        x = 4;
    }

A. 0
B. 4
C. Compile time error
D. Undefined

Answer: B
----------------------------------------------------------------------------------------------------------------

8.
Find the output?

#include
    void main()
    {
        {
            int x = 8;
        }
        printf("%d", x);
    }

A. 8
B. 0
C. Undefined
D. Compile time error

Answer: D
-----------------------------------------------------------------------------------------------------------------

9.
What will be the output of following program

#include
main()
{
int x,y = 10;
x = y * NULL;
printf(\"%d\",x);
}

A. error
B. 0
C. 10
D. Garbage value

Answer: B
-----------------------------------------------------------------------------------------------------------------
Previous Page                  Home                    Last Page
-----------------------------------------------------------------------------------------------------------------

More Imp Topics:

Operators
Pointers
Array
Preprocessor
Structures
Control Structures
Switch Case
Printf
Variables


100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...