Friday, February 17, 2012

Predict the output Of the following Code snippet:


 void main()

void display()
     printf("\n Cliffhanger");

Ans:  Redeclaration error

Reason ::::
Here display() is called before it is defined. In such cases the compiler assumes that the function display() is declared as int display(); That is , an undeclared function is assumed to return an int and accept an unspecified number of arguments. Then when we define the function display() the compiler finds that it is returning void hence the compiler reports the discrepancy.

No comments:

Post a Comment