The following Code is working. But in the book, I am studying it is said, that I should read in two numbers. And when the character 'N ' comes, the while-loop should stop. So now, I am not sure about the way I solved this problem, because I think the code should not have a cin >> stop; and stop automaticcaly when something other than a int-valueget got written in.
Can anybody explain me how I can solve this problem? Sorry for my bad english...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
usingnamespace std;
int main()
{
int number_1 = 0;
int number_2 = 0;
char stop = 'a';
while (stop != 'N'){
cout << "Enter two numbers:" << endl;
cin >> number_1 >> number_2;
cout << number_1 << ' ' << number_2 << endl;
cout << "Would you like to continue with writing in Numbers? Write Y or N:" << endl;
cin >> stop;
}
return 0;
}