Why we use return( ) in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we use return( ) in c++?

11th Dec 2016, 6:07 AM
ashish parmar
ashish parmar - avatar
3 Answers
+ 1
sometimes we want dunction to return some value may be integer , string,float ,chars. for that we use return . we return data whose tyoe matches with return type. i case of void - void means null i.e. no return type hence we never return somthing
11th Dec 2016, 8:29 AM
manish rawat
manish rawat - avatar
0
int main() { return 0; } is a global function and like all functions must return a value, even void (the value is no value.)
11th Dec 2016, 7:19 AM
JENN
JENN - avatar
0
it is required to return a value especially if your function has a return value like int, float, double, etc. if you want a function that is not returning a value use void return type.
11th Dec 2016, 8:29 AM
Jotwa
Jotwa - avatar