An unusual problem has appeared in this code:
#include <iostream>
using namespace std;
int main()
{
int number;
bool repeat=true;
while (repeat)
{
cout<<"\nEnter a number:";
cin>>number;
cout<<"\nNumber is:"
<<number;
cout<<"\nRepeat?:";
cin>>repeat;
}
system("pause");
return 0;
}
here in this code when i put the character such an βAβ into an int variable when the loop repeats over and over and donβt ask me whether to repeat or not. this problem occurs when I put characters in non-integer numbers. it also appears.
why should this happen? thank
source
share