Write the output of the following program: int a[ ] = {1,2,3,} *p;

Options

  • A. Junk value
  • B. 3
  • C. Runtime error
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

E. None of the above

Detailed Explanation

Explanations:

The given code snippet is:

inta[] = {1,2,3,} *p;

Analysis

This declaration is syntactically incorrect in C.

Correct declarations could be:

inta[] = {1,2,3};
int*p;

or

inta[] = {1,2,3}, *p;

But writing

inta[] = {1,2,3,} *p;

is invalid syntax, so the program will not compile.

Conclusion

Since the program does not compile, there is no output and it is not a runtime error.

OOps! You are currently offline.