close

3.17.jpg  

#include <stdio.h>
#include <stdlib.h>

int main()
{
    float gallons, miles, averg, avergs = 0;
    int count = 0;
    
    while( gallons != -1 )
    {
          printf("Enter the gallons used (-1 to end): ");
          scanf("%f",&gallons);
          if ( gallons == -1 )
          {
            printf("The overall average miles / gallon was %f",(avergs / count));
            break;
          }
          else
          {
            printf("Enter the miles driven: ");
            scanf("%f",&miles);
            averg = miles / gallons;
            printf("The miles / gallon for this tank was %f\n",averg);
            count++;
            avergs = avergs + averg;
          }
          
    }
    system("PAUSE");
    return 0;
}


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Icen Zhong 的頭像
    Icen Zhong

    無止盡的Coding地獄

    Icen Zhong 發表在 痞客邦 留言(0) 人氣()