+ 1

When we use program (hello world )these are characters so why should we use int function ?

Int main() Printf("hello wold");

12th Jan 2021, 2:16 AM
yashika rattu
yashika rattu - avatar
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() )
12th Jan 2021, 2:59 AM
Arsenic
Arsenic - avatar
+ 2
Thanks buddy 👍
12th Jan 2021, 3:05 AM
yashika rattu
yashika rattu - avatar
+ 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.
12th Jan 2021, 2:24 AM
Daniel Briceño
Daniel Briceño - avatar
0
My doubt is not clear🤔
12th Jan 2021, 2:34 AM
yashika rattu
yashika rattu - avatar
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 ?
12th Jan 2021, 2:36 AM
yashika rattu
yashika rattu - avatar
0
It is usually done like this: int main(){ return 0; } because that is how it indicates that everything ended as it should.
12th Jan 2021, 2:39 AM
Daniel Briceño
Daniel Briceño - avatar
0
try to return char to see how it comes out. remember that programming is made of magic and error
12th Jan 2021, 2:41 AM
Daniel Briceño
Daniel Briceño - avatar