+ 1
Difference between int main() and void main()
7 Answers
+ 4
The void main() indicates that the main() function will not return any value.
But ,the int main() indicates that the main() can return integer type data.
As void means nothing or null
+ 4
int main() -->returns an Integer value.
void main()--->returns nothing..
int and void are datatypes that defines the function.
+ 2
The main() function is like other functions. It also takes arguments, and returns some value. One point we have to keep in mind that the program starts executing from this main() function. So the operating system calls this function. When some value is returned from main(), it is returned to operating system.
The void main() indicates that the main() function will not return any value, but the int main() indicates that the main() can return integer type data. When our program is simple, and it is not going to terminate before reaching the last line of the code, or the code is error free, then we can use the void main(). But if we want to terminate the program using exit() method, then we have to return some integer values (zero or non-zero). In that situation, the void main() will not work. So it is good practice to use int main() over the void main()
+ 2
Welcome to SoloLearn forum!
This question is frequently asked.
Remember to use the search bar next time to avoid duplicates.
https://www.sololearn.com/discuss/81360/?ref=app
https://www.sololearn.com/discuss/1732536/?ref=app
https://www.sololearn.com/discuss/80098/?ref=app
https://www.sololearn.com/discuss/356691/?ref=app
https://www.sololearn.com/discuss/258068/?ref=app
https://www.sololearn.com/discuss/1225/?ref=app
Welcome again.
https://www.sololearn.com/discuss/1316935/?ref=app
0
What's the meaning of return in a function
0
A word before 'main()' function represents the return type.
If it is 'void' that's means the function doesn't return anything.
And if it int, that's mean the function will be return an integer.
0
void main() without any output but int main() send output with return(<int value>); to where call the app for example console.