Trying to make a C program that takes eg. 5 user inputs in a float array. Then prints the array and prints another array that accumulates the numbers. It works fine but how do i break the input and print "not a number" if the input is non-nummerical?
#include <stdio.h>
int main(){
float i,sum;
sum=0;
const int ARRAYSIZE = 5;
float array1[ARRAYSIZE];
printf("Input a number (a total of %d numbers is needed):\n", ARRAYSIZE);
fflush(stdout);
for(int i = 0; i < ARRAYSIZE; i++){
scanf("%f", &array1[i] );
}
for(int i = 0; i < ARRAYSIZE; i++){
printf("You typed in: %.2lf\n",array1[i]);
}
for(int i = 0; i < ARRAYSIZE; i++){
sum+=array1[i];
printf("The accumulated value if the input is: %.2lf\n", sum);
}
return 0;
}