how to accept user input??? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

how to accept user input???

what i have to write when ''Seems like your program requires input'' shows ?? on that function #include <iostream> using namespace std; int main() { int a; cout << a+5; cin >> a; cout << a; return 0; } give me some examples, please... i cant understand :/

4th Nov 2016, 11:13 AM
dghi
dghi - avatar
4 Respostas
+ 2
cout is used to send output to console and cin use for input that take user input in your program cin has used for get value from user and insert it to variable, it is compulsory to store data in a variable.
4th Nov 2016, 11:21 AM
Aditya kumar pandey
Aditya kumar pandey - avatar
4th Nov 2016, 11:11 AM
Sahand Mirzaee
Sahand Mirzaee - avatar
+ 1
thx :)
4th Nov 2016, 11:26 AM
dghi
dghi - avatar
+ 1
You are adding 5 to an unassigned variable a. First of all, cout stands for "console output", so you output data like text or numbers. cin stands for "console input", so, for example, cin >> a; you assingn value to variable a. #include <iostream> using namespace std; int main(){ int a; // Okay, you created variable a. cin >> a; //Waiting for user input, for example, number 3. cout << a + 5; //Adds a, which is 3 with 5 and output will be 8; return 0; }
4th Nov 2016, 1:26 PM
Karolis Strazdas
Karolis Strazdas - avatar