# average for numbers inputed

The average kept coming out wrong.
float total = 0;
for(i = 0; i < 9; i++) {
total += array[i ];
}

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.
###### Who is Participating?

Commented:
>  im using the basic numbers 1, 2,3, 4, 5, ,6 ,7, 8, 9
the ,, between the 5 and 6 would be a syntax error
float average = total/9.0;
or
will do a floating  division rather than an integer division
0

Commented:
You should write it as follows:

float total = 0;
for(i = 0; i <= 9; i++) {
total += array[i ];
}

0

Commented:
Sorry that was incorrect, it should be:

float total = 0;
for(i = 0; i < 9; i++) {
total += array[i ];
}

0

Author Commented:
I have, the average comes out wrong still.
0

Commented:
What is the result that you get?
0

Author Commented:
That worked, Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.