Hello everyone I'm a beginner to coding and I would like some help with something I have encountered while trying to write some code. This is not homework just something I am doing for fun to try to advance my coding skills a little bit more. I am building code that will take 3 numbers that the user inputs then finds the average of those 3 numbers. I have that part down but I'm trying to think of some ways I can go about figuring out error handling situations such as if someone puts a letter instead of a number I would like it to cout "Error must type in a number". But I'm not sure what code I would use exactly.. I know it should need an if statement that states if int does not equal a number, then cout error message but I'm lost when it comes to the syntax. Any ideas as to how I can go about this? Below is what I have so far.
#include <iostream>
usingnamespace std;
int main()
{
int a;
int b;
int c;
int average;
cout << "Enter a number: " << endl;
cin >> a;
cout << "Enter another number: " << endl;
cin >> b;
cout << "Enter your last number: " << endl;
cin >> c;
average = (a + b + c) / 3;
cout << "Average is:\n" << average << endl;
system("pause");
return 0;
}