C++ functions question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

C++ functions question

Hi all, For some reason I had to split up my question-tekst into two parts, otherwise I got errors.

7th Sep 2018, 11:22 AM
Sabine Meijran-Prins
Sabine Meijran-Prins - avatar
5 Answers
+ 5
https://code.sololearn.com/ccmRwaifI8Nz/?ref=app the variable answer is defined only inside function so by calling and printing the value of answer variable it will give error of variables not defined in main define the variable in main you will print value of answer saw above code
7th Sep 2018, 11:47 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 4
please specify more what you want to ask on function, till that go through this it will help https://www.sololearn.com/learn/CPlusPlus/1635/?ref=app
7th Sep 2018, 11:24 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
I have a question. I was watching the following bucky video about C++ functions(https://www.youtube.com/watch?v=fQ_CBGVfGbM) What I do not understand is that you have to cout the addNumbers and not the answer. To me it sounds more logic to print out on screen (cout) the answer(variable)… Any explanation would be helpfull :)
7th Sep 2018, 11:23 AM
Sabine Meijran-Prins
Sabine Meijran-Prins - avatar
+ 1
Thank you all for the answers. Sketch, yes of course you are so right.. thank you so much..
7th Sep 2018, 1:52 PM
Sabine Meijran-Prins
Sabine Meijran-Prins - avatar
0
cause the variable answer only exist inside the addNumber functions. calling variable answer outside the function will create an error
7th Sep 2018, 11:32 AM
Sketch
Sketch - avatar