- 1

What will happen if we use void instead of int ??

12th May 2020, 8:33 PM
Arghya Singha
Arghya Singha - avatar
7 Answers
+ 2
function will not return anything. void means no return type.
12th May 2020, 8:38 PM
A͢J
A͢J - avatar
+ 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
12th May 2020, 9:01 PM
Ore
Ore - avatar
+ 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++.
13th May 2020, 12:47 AM
Arsenic
Arsenic - avatar
0
#include<studio.h> Int main(){ } And #include<studio.h> void main (){ } These two codes are giving same output
12th May 2020, 8:41 PM
Arghya Singha
Arghya Singha - avatar
0
Oohh
12th May 2020, 8:44 PM
Arghya Singha
Arghya Singha - avatar