+ 1
When we use program (hello world )these are characters so why should we use int function ?
Int main() Printf("hello wold");
8 Antworten
+ 6
yashika rattu , here you are not returning ("hello world") from the main() function but printing them on the console instead, your main() is still returning an integer only.
According to the C/C++ standards, main() must return an integer after it's complition which will be returned to your operating system and is up to you if you want to use it or not. ( Generally used to find the status of program when it exited ) and the value you are returning doesn't matter if you are not using it for anything.
As BeegCat said, if you do not write any return statement in main() then some morden compilers by default add it for you (only for the case of main() )
+ 2
Thanks buddy 👍
+ 1
Every c or c ++ program must return an integer value to the machine. When it returns zero it means that the program finished the execution without errors, and when it returns any other number it means that there is an error. In other words, every c or c ++ program must return an integer for the machine.
0
My doubt is not clear🤔
0
I gotted that computer consist integers while program run or not .
But now I have nothing to return so why should we use integer there should be use char function ?
0
It is usually done like this:
int main(){
return 0;
}
because that is how it indicates that everything ended as it should.
0
try to return char to see how it comes out. remember that programming is made of magic and error