0
difference between return and cout
what is the difference between return and cout return a+b; cout<<a+b;
1 Answer
+ 2
Cout is equivalent to printing something out. Return is for functions, and is the result of whatever the function does. So, you could do something like this:
int sum(n1, n2) {
return n1 + n2;
}
cout << sum(5, 8) << endl;
cout << 5 + 8 << endl;
// Both couts do the same thing