1
2
3
4
5
6
7
8
| main()
{
show();
}
void show()
{
printf("I'm the greatest");
} |
main()
{
show();
}
void show()
{
printf("I'm the greatest");
}
Click here to view the answer
Answer:
Compier error: Type mismatch in redeclaration of show.
Explanation:
When the compiler sees the function show it doesn’t know anything about it. So the default return type (ie, int) is assumed. But when compiler sees the actual definition of show mismatch occurs since it is declared as void. Hence the error.
The solutions are as follows:
1. declare void show() in
main() .
2. define show() before main().
3. declare extern void show() before the use of show().