Home / CSE MCQs / C-MCQs :: Discussion

Discussion :: C-MCQs

  1. What is the output of this C code?

    int main()
    {
    printf("Hello World! %d \n", x);
    return 0;
    }
  2. A.
    Hello World! x;
    B.
    Hello World! followed by a junk value
    C.
    Compile time error
    D.
    Hello World!

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    It results in an error since x is used without declaring the variable x.
    Output:
    $ cc pgm1.c
    pgm1.c: In function 'main':
    pgm1.c:4: error: 'x' undeclared (first use in this function)
    pgm1.c:4: error: (Each undeclared identifier is reported only once
    pgm1.c:4: error: for each function it appears in.)


Be The First To Comment