Arsenic "дяволче" Iodide (siliconstitches) wrote in cprogramming,
Arsenic "дяволче" Iodide
siliconstitches
cprogramming

  • Mood:
  • Music:

In dire need of help. ;.;

So i've been starring at this code and manipulating it for who knows how many hours now and it's finally beginning to drive me insane.

The program is supposed to sum up a bunch of grades and then calculate the average, but the average always comes out to be 16. I am blind to see the problem in code thus far. Any suggestions?

int main(){

int i = 0;
float SumEx = 0;
float AvgEx;
float OneExVar;

printf("Enter exam value:\n");
scanf("%f", &OneExVar);

while(SumEx >= 0){

printf("Enter next exam value:\n");
scanf("%f", &SumEx);

i = i + 1;

}

AvgEx = (SumEx + OneExVar)/(i + 1);

printf("The average is: %5.2f\n", AvgEx);

}
  • Post a new comment

    Error

    default userpic
  • 11 comments