+ 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 ???

4th Sep 2017, 12:21 PM
Ignacio MS
Ignacio MS - avatar
8 Antworten
+ 6
If your program expects the value 10 simply enter 10 If there are multiple inputs put each on its own line.
4th Sep 2017, 12:27 PM
jay
jay - avatar
+ 6
so for two numbers say 5 and 5 enter them like so: 5 5
4th Sep 2017, 12:46 PM
jay
jay - avatar
+ 5
😊 I figured I would use your example
4th Sep 2017, 12:45 PM
jay
jay - avatar
+ 1
My program expects any number 10 was just an example
4th Sep 2017, 12:44 PM
Ignacio MS
Ignacio MS - avatar
+ 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
4th Sep 2017, 12:45 PM
Ignacio MS
Ignacio MS - avatar
+ 1
But Thanks
4th Sep 2017, 12:45 PM
Ignacio MS
Ignacio MS - avatar
+ 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
4th Sep 2017, 1:06 PM
Sindhu Lingaraju
Sindhu Lingaraju - avatar
0
int a=10;
4th Sep 2017, 7:26 PM
ephi