I wrote the code to ask the user to input 5 numbers. They are then passed to a new function named sum where they are added together and then sent back to the main. In the main I then find the average.
I want to write something that says "error" if the user input anything besides a number during the input of data at the start.
int main()
{
//input data
float a, b, c, d, e, ans, final;
cout<<"Enter the first value""\n";
cin>>a;
cout<<"Enter the second value""\n";
cin>>b;
cout<<"Enter the third value""\n";
cin>>c;
cout<<"Enter the forth value""\n";
cin>>d;
cout<<"Enter the fifth value""\n";
cin>>e;
ans=sum(a, b, c, d, e);// sent to z_function
final=ans/5;
cout<<"The answer is "<<final<<"\n";