Home / CSE MCQs / C-MCQs :: Discussion

Discussion :: C-MCQs

  1. What is the output of this C code?

    int main()
    {
    int y = 10000;
    int y = 34;
    printf("Hello World! %d\n", y);
    return 0;
    }
  2. A.
    Compile time error
    B.
    Hello World! 34

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    Since y is already defined, redefining it results in an error.
    Output:
    $ cc pgm2.c
    pgm2.c: In function 'main':
    pgm2.c:5: error: redefinition of 'y'
    pgm2.c:4: note: previous definition of 'y' was here


Be The First To Comment