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)
3 Answers
+ 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;
+ 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
0
okay thanks.