code similar to tutorial yet when pressed 0 it gives the average and then ends the progam. why?

0 krishna dhoot · February 26, 2015
# include <stdio.h>
int main()
{
   float scoreentered=0, tests=1, average=0, grade=0;
do
   {

       printf("\nenter the score: ");
       scanf("%f",&scoreentered);
       grade+=scoreentered;
       average=grade/tests;
       printf("\ntests:%.0f, average: %.2f ",tests,average);

       tests++;
    }
while(scoreentered!=0);
return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
0 c student · February 26, 2015
while (scoreentered != 0);    /* quit loop when scoreentered is 0 */
  • 1

C

107,060 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator