+ 5
Can you please tell me,the diffenrence between void main(),and int main().
Explain it.
8 Respostas
+ 7
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 :)
+ 5
//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đđ„
+ 1
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
+ 1
Void main() doesn't return any value but int main() will return integer value.Hope this will help youđđ
+ 1
Void main() means returns null value where int main() means function returns integer value
0
Int main requires return type conformly but void main requires some times only and int main shows data type
0
Void main does not require any return type. But int main need return type to be execute the code
0
For Void main there is no return type