-
What will be the output of the following C code having void return-type function?
#include <stdio.h>
void fun()
{
return 5;
}
void main()
{
int n = 4;
n = fun();
printf("%d", n);
}
-
- 5
- 4
- Compilation Error
- Runtime Error
- None of these
Correct Option: C
Compilation Error
main.c: In function ‘fun’:
main.c:4:16: warning: ‘return’ with a value, in function returning void
return 5;
^
main.c:2:10: note: declared here
void fun()
^~~
main.c: In function ‘main’:
main.c:9:11: error: void value not ignored as it ought to be
n = fun();