having cin statements added via a loop

Hi there

is it possible to have cin statements added in as a if they were a variable
for example

pseudo code follows

int main ()

aa = cin>>word

if x == example,
{
cout <<"please enter in a word: \n"<< aa;
}

or because they are hardcoded functions, they cant be used as such and has to be done as a loop or such?

I was able to accomplish this with if else statements but with the cin statements already declared, Im trying not to declare cin in each if else statement if possible

many thanks!

You can do this
1
2
3
while ( cin >> word ) {
  cout << "You typed " << word << endl;
}
Do the following for breakable loop:
1
2
3
4
do {
    cin >> word;
    cout << "You typed " << word << endl;
} while (word != exitWord);
Topic archived. No new replies allowed.