Sir,I am not able to get what is main function and how it is called and how it is exected, and why only 0 is returned as a value and why we dont use void main()
Main() & return 0
hello @rizvibilal10
int main is the function that is called by the operating system during exection.
it is the very first function of ur program runs during execution.
return 0 ; is telling os that this program has eecuted successfully.
so basically values returned from main function is used by os to decide whether program excution is done successfully or not
Ohh so this is default in OS in c++ or other languages also?
I mean in other programming languages also returning 0 means the program is executed successfully?
And sir why we dont use void main().
Yes sir read this earlier,I still didn,t get it…
Please sir,can u explain in short,I am a beginner I dont know much.
there are some standards fixed for c++.
return int is one of them.
that why whever u will try to compile c++ without int
it will give u error. ( main’ must return ‘int’)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.