Can you please tell me,the diffenrence between void main(),and int main().

Explain it.

4/17/2019 9:01:09 AM

M Raghavendra

7 Answers

New Answer


Here are some answers to your question, including mine 👍😉 https://www.sololearn.com/Discuss/1732536/?ref=app


Hi M Raghavendra There is a search function for the Q&A Discussions area which you many use to find many commonly asked questions. Here is one example I found. https://www.sololearn.com/Discuss/1492571/?ref=app There are many more, give the search function a try :)


//doesn't have a return statement //(void = nothing) void main(){ //some code } //returns an ineger //integer = number int main(){ //some code return 1; } //returns boolean //true/false bool main(){ //code return true; } Of corse, the number "1" could be an variable and be like return variablename; or something, but i hope you understood what i mean. int main() returns an int, bool main() returns a boolean and void main() returns nothing. If not, have a look at Datatypes😉🔥


using return type will allow: If u want to use the output of a function later in the code or want to do more processing u can store it in a separate variable. By using same Kind of variable as the return statement will give you you int squAre(int a) { return a*a; } int c = squAre(3); OR you can directly print it: cout<<squAre(3) void: on the other side if you use void you will not be able to get the output of the code(mean you can get the result in a variable easily ... but to get this you can use reference an store the out put value in a variable


Void main() doesn't return any value but int main() will return integer value.Hope this will help you👍😊


Int main requires return type conformly but void main requires some times only and int main shows data type


Void main() means returns null value where int main() means function returns integer value