I get the idea of how this work but I don't really understand how did it bring the information by using printDouble(num);
int num {getvaluefromuser()} would go to first int getvaluefromuser. Then back to printdouble(num);
printdouble(num); go to void printdouble and it'll get value with * 2.
so my question did the (num): bring the value from void printDouble(int value) because the (num) would refer to (int value) in void part?
Im confuse where exact thing go from there to there.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
int getValueFromUser()
{
std::cout << "Enter an integer: ";
int input{};
std::cin >> input;
return input;
}
void printDouble(int value) // This function now has an integer parameter
{
std::cout << value << " doubled is: " << value * 2 << '\n';
}
int main()
{
int num { getValueFromUser() };
printDouble(num);
return 0;
}
|
I need to understand of where step to step it goes.
example
step 1... int num {getValueFromUser()};
step 2... cout << "etc" then get input/
step 3... return input to int main()
step 4... printDouble(num); .. that where I'm lost.
I suspect
step 4...(int value) would refer to int num then
step 5...printDouble(num)
step 6...then it sent to int getValueFromUser().