0

how to use cout and cin at the same time?

How to make user enter a number and the output the number on screen like this: you have selected number(your entered number)

12th Feb 2017, 10:14 PM
JuLLe //Rq
JuLLe //Rq - avatar
3 Respostas
+ 15
You can't write both in the same line, it will give you the compilation error. But you know that you can write it separately? int x; cin>>x; cout<<"Your number is: "<<x;
12th Feb 2017, 10:27 PM
Filip
Filip - avatar
+ 1
you can't use it with cin and cout, however there is a work around using getch and getche(). char c; while (true) { cout << "you have selected number : "; c = getche(); cout << endl; } if you don't want to display what you type on the screen, use getch() instead of getche(). however, this only takes a single character as an input, so you can only input a single digit number. use arrays for more than 1 digit
13th Feb 2017, 1:46 AM
Nikunj Arora
Nikunj Arora - avatar
0
okay thanks.
13th Feb 2017, 9:24 PM
JuLLe //Rq
JuLLe //Rq - avatar