Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is the output of this C code?

#include <stdio.h>
    struct student
    {
        int no;
        char name[20];
    }
    void main()
    {
        struct student s;
        s.no = 8;
        printf("hello");
    }

 

  • A.Compile time error
  • B.Nothing
  • C.hello
  • D.Varies

Answer: A

Correct answer: Compile time error

The structure definition is missing its terminating semicolon after the closing brace. Without it the compiler reads on and tries to make sense of void main() as part of the declaration, and the program fails to compile.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.