+ 3
What's the difference between printing the value and returning it ?
Print or return
6 Respuestas
+ 5
When you use print actually you force the function to print the output always. But do you want to print always? No! Sometimes you want to use it in another procedure so you should use return instead of print to it be usable for different occasions.
+ 4
print: takes what is inside the () and prints it in the console, the value can't be taken from there.
=> only for testing / giving output
return: only present inside a function. returns the content of a variable or a constant value, which can be used outside the function.
=> without it more than half of all functions wouldn't work/had no use
totally diffrent!
, but a value that is returned by a function can be printed too
=> make all functions return a value and then print it for testing purposes or for the actual output
+ 3
returning returns a value to where the function was called. Printing is a basic way to display data to user.
+ 1
Can you give code example please ? Try to make the code the same way you explained it.
C++.
+ 1
The unknown 321 when you use return the value you get can be modyfied and used in multiple was, printing will just output it so the user can get info ...