+ 4

What happen if we don't use return statement?

2nd Sep 2016, 9:00 AM
ANKUSH KUMAR
ANKUSH KUMAR - avatar
6 Réponses
0
If your function doesn't return anything, set the return type to void. void print(int n) { cout << n; } Similarly, if it doesn't take any parameter, put void in the parameter field. int get42(void) { return 42; }
2nd Sep 2016, 1:14 PM
Zen
Zen - avatar
0
In the main function, nothing may happen but it will be difficult for you to even notice a logical error in your code since you wouldn't be able to see the required value returned after program execution.
2nd Sep 2016, 10:31 PM
Bless Darah Gah
Bless Darah Gah - avatar
0
it doesn't return a particular value which u want in the main function i.e if u doing a calculation in ur function and when u pass an argument to the function ..it will do the calculation and it wont return the answer to place where u called..
23rd Oct 2019, 3:35 AM
Naryan Poudel
Naryan Poudel - avatar
0
si
13th May 2021, 11:54 AM
oriol navarro martin
oriol navarro martin - avatar
0
diam
6th Dec 2021, 2:16 AM
zaira alya
- 1
it doesn't return a particular value which u want in the main function i.e if u doing a calculation in ur function and when u pass an argument to the function ..it will do the calculation and it wont return the answer to place where u called..
2nd Sep 2016, 10:05 AM
balaji
balaji - avatar