hello, this is my first few weeks of coding, and i was hoping you fine people could give me some help (no one else wants to).

i have a simple program to find the length of a hypotenuse, now the problem is that when the user inputs a letter or word instead of a number, the program loops continuously. how do i get the program to ignore letters and words and take only integers?

here is the source if it helps:

int main()
{
int x, y;
cout<<"Please give me the two legs of the triangle."<<endl;
cout<<"First leg: "<<endl;
cin>>x;
cout<<endl<<"Second leg: "<<endl;
cin>>y;
cout<<endl<<"one moment please..."<<endl;
cout<<"the hypotenuse length is "<<sqrt(x*x+y*y)<<endl<<endl;
return 0;
}