hellow every one,i have a question i have an array which have some index are empty and they are in the last of course,so i want to compute the average of all the indexs put i dont now when to stop the loop since the lenth of the array is 50
this is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void averagescore(int scores[50])
{
int total=0;
int x=0;
for(int i=0;i<=50;i++)
{
total =total+ scores[i];
x++;
if (scores[i]='\n')//realy i didnt know what to put in the condition so i did this
break;
}
cout<< "the average of the scores" <<total/x<<endl<<x<<endl;//after all of this the loop reads only the first index and get the avrage of it
}
these are the index of the array :88 87 88 66 55 56 75 75 78 80 80 90 99 87 44 34 0 100
is there any suggestions!!!