What is the use of the return function in c programming? How relevant can it get?why it is usually followed by 0 and not other? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the use of the return function in c programming? How relevant can it get?why it is usually followed by 0 and not other?

As a beginner, when I learn simply code like printing Hello world the function usually ends by writing return (0); when I omitted it , the program works. When I change the number, the program works. So, why we really use return statement

29th Mar 2022, 12:24 PM
Amanuel Nigussie
2 Answers
0
return can be followed by an integer or string as well. Generally, it specifies the the value a function returns to another function which called it.
29th Mar 2022, 12:31 PM
Infinity
Infinity - avatar
0
The return statement is used to see if a problem occured in the program. If it returns 0, then it had no errors. Anything other than 0 usually tells you and error occured
29th Mar 2022, 12:55 PM
Slick
Slick - avatar