Home / CSE MCQs / C-MCQs :: Discussion

Discussion :: C-MCQs

  1. What is the output of this C code?

    void main()
    {
    int k = 4;
    float k = 4;
    printf("%d", k)
    }
  2. A.
    Compile time error
    B.
    4
    C.
    4.0000000
    D.
    4.4

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    Since the variable k is defined both as integer and as float, it results in an error.
    Output:
    $ cc pgm8.c
    pgm8.c: In function 'main':
    pgm8.c:5: error: conflicting types for 'k'
    pgm8.c:4: note: previous definition of 'k' was here
    pgm8.c:6: warning: format '%d' expects type 'int', but argument 2 has type 'double'
    pgm8.c:7: error: expected ';' before '}' token


Be The First To Comment