+ 1
How do we get to know where to use void main and where to use int main
2 Answers
+ 1
Int is return type of our output
Suppose a function
int func()
{
Int c = 10;
return c;
}
Here we return some variable c that has integer datatype
So we use int data type for our function
But supposed function like this
void func(){
cout << "Hello";
}
Here we return nothing not use return keyword.
So we used void here
+ 14
Palakh Koyalkar
We use int main(), when we are returning int data to main().
With int as return type we also write return 0; at the end of program to show that program executes successfully as main() returns value to OS.
And use void main() , when main() is not returning any value (data) .