Alright so I have a homework question that I'm a little confused about. I'm pretty new to C/programming in general, so this is probably actually really simple...
I just don't understand how you would have it count how many negatives and positives there are based on the user's input?
If anyone could assist me in any way that would be super great!
Here's the problem and the code it provides:
Modify the program so that is displays the average of the positive and negative numbers. (Hint: be careful not to count the number 0 as a negative number.)
Code:#include <stdio.h> #define MAXNUMS 5 int main() { int i; float number; float postotal = 0.0f; float negtotal = 0.0f; for (i =1; i <= MAXNUMS; i++) { printf("Enter a number (positive or negative) : "); scanf("%f", &number); if (number > 0) postotal += number; else negtotal += number; } printf("\nThe positive total is %f", postotal); printf("\nThe negative total is %f\n", negtotal); return 0; }