Thursday, February 14, 2008

Aptitude Question No.15

Aptitude Question No.15

main()
{

char string[]="Hello World"; 15
display(string);
}
void display(char *string)
{
printf("%s",string);
}
Answer
Compiler Error : Type mismatch in redeclaration of function display
Explanation :
In third line, when the function display is encountered, the compiler doesn't know anything about the function display. It assumes the arguments & return types to be integers, (which is the default type). When it sees the actual function display, the arguments & type contradicts with what it has assumed previously. Hence a compile time error occurs

No comments:

2008 Placement papers of Top MNC companies

eXTReMe Tracker