- 1
What will happen if we use void instead of int ??
7 Antworten
+ 2
function will not return anything. void means no return type.
+ 1
In C. Every method's return type must be explicitly defined while defining the method.
For example,
int my_method(){} as a return type of int so it must return a int value or an error is raised.
That is why main() has return type of int since it returns 0.
If the return type is void then nothing must be returned
+ 1
Arghya Singha , in case of main() function , most of the modern compilers use return value of main() as the exit status of program, which should be an integer. So if your main is returning anything else than an integer, it is considered illegal in C/C++.
0
#include<studio.h>
Int main(){
}
And
#include<studio.h>
void main (){
}
These two codes are giving same output
0
Oohh