0
What's the difference between : {cout << x*2 ;} and {return x*2;} in a function?
functions
2 Answers
+ 1
cout << x * 2; will put the result of x * 2 into the output stream and print it (usually to the console/terminal window).
Example where x = 5:
cout << x * 2; // prints 10 in the console
Where return x * 2; will return the result of x * 2 to the function call.
example:
int getNumber(int x) { return x * 2; }
int y = getNumber(10); // y = 20
+ 1
thank u đđ