#declararion
24 messages ยท Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
!format
#include <iostream>
int doubleNumber() {
std::cin >> x;
int x{};
return 2 * x;
}
int main() {
int x{doubleNumber()};
std::cout << x << '\n';
}
;solved
are you sure this works @slender flint ?
No it doesn't thats why I was about to ask lol
so think about how variables work
what needs to happen for you to use them?
This std::cin>>x; is input then after the input,the input is stored in the variable int x{};
Its logical this way for input to afterwards go in the variable
You can't start with the variable then input doesn't make sense
hm i will have to correct you ๐
the problem is, if x is not defined when you take input from std::cin, where does the input go?
think of it this way
if there's no basket to collect fruits in, where do i store the fruits?
The fruits are input and the basket is variable
Before variable there's fruit
yes but in our case the fruit really needs a basket
it needs to know that there's a basket otherwise it will say "I cannot jump into the dark, I'll die!"
"I cannot jump into the dark"
Jump is starting point once you reach the basket its ending point
yes but at that point in time, the basket doesn't really exist now, does it?
the basket comes into existence once the fruit has already dropped into the abyss, because that's what you decided to do
Unless to your understanding and expertise according to c++ language
They has to be evidence of a container before I put something in, ..........then I'll just have to agree.
i don't quite understand. I'm not a native speaker ๐
Oh yeah
!solved