In C code. This is the part I want to work on below. I want to be able to do... if a character value then say \"not a number\", however, because it is an array and it increments
If you want to repeat something, you need a loop. If you don't know how many times you'll want to loop in advance, it's probably going to be a while
loop. The following structure will achieve your goal cleanly:
while (1) {
printf("Enter salary for Employee #%d: ", i + 1);
scanf("%f", &sal[i]);
if (...valid...)
break;
printf("Not a Number. Try again.\n");
}
The value returned by scanf
will help you determine if the input was valid. I will leave consulting the documentation and finishing that part of your homework to you.