HelpMeMaggi
asked on
average for numbers inputed
The average kept coming out wrong.
int add = 0;
float total = 0;
for(i = 0; i < 9; i++) {
total += array[i ];
add++;
}
float average = total/9;
why does the average not add up right, im using the basic numbers 1, 2,3, 4, 5, ,6 ,7, 8, 9 so i know the correct average.
int add = 0;
float total = 0;
for(i = 0; i < 9; i++) {
total += array[i ];
add++;
}
float average = total/9;
why does the average not add up right, im using the basic numbers 1, 2,3, 4, 5, ,6 ,7, 8, 9 so i know the correct average.
Sorry that was incorrect, it should be:
int add = 0;
float total = 0;
for(i = 0; i < 9; i++) {
total += array[i ];
add++;
}
float average = total/add;
int add = 0;
float total = 0;
for(i = 0; i < 9; i++) {
total += array[i ];
add++;
}
float average = total/add;
ASKER
I have, the average comes out wrong still.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is the result that you get?
ASKER
That worked, Thank you!
int add = 0;
float total = 0;
for(i = 0; i <= 9; i++) {
total += array[i ];
add++;
}
float average = total/add;