Is there any way to check whether the user has inputed an integer or string, for example I want to tell the user when he has entered a letter in the following program which adds the numbers with previous,that "invalid input,please only insert numbers" ? it seems when I enter letter as input it forms an infinite loop.Code:#include <iostream>
using namespace std;
int main()
{
int x;
cin>>x;
int y;
while (true){
cin>>y;
cout<<x+y;
x=x+y;
}
}