+ 2
How to input a variable
When I was doing the "Working With Variables" Lesson I tried to input a variable into the code when the message Seems like your program requires an input appeared How do I input the value in? EX: \10 or Please enter a number \10 or ???
8 Antworten
+ 6
If your program expects the value 10 simply enter 10
If there are multiple inputs put each on its own line.
+ 6
so for two numbers say 5 and 5 enter them like so:
5
5
+ 5
😊 I figured I would use your example
+ 1
My program expects any number 10 was just an example
+ 1
int main()
{
int a, b;
int sum;
cout << "Enter a number \n";
cin >> a;
cout << "Enter another number \n";
cin >> b;
sum = a + b;
cout << "Sum is: " << sum << endl;
return 0;
}
Run this code in the playgrounds to see what I mean
+ 1
But Thanks
+ 1
Just give in this way if you want to input a=10 and b=20 do like this
10
20
Then u will get the output
0
int a=10;