fork download
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. double gallon1,gallon2,gallon3,mile1,mile2,mile3;
  6.  
  7. printf("Welcome to the Sears mileage calculator.\n\n");
  8.  
  9. printf("This program will calculate the miles per gallon for you for three tanks of gas\n");
  10. printf("after you have entered the gallons used and miles driven.\n\n");
  11.  
  12. printf("Enter the number of gallons used for tank #1: ");
  13. scanf("%lf",&gallon1);
  14. printf("Enter the number of miles driven : ");
  15. scanf("%lf",&mile1);
  16.  
  17. printf("*** The miles per gallon for this tank is %.1lf\n",mile1/(double)gallon1);
  18.  
  19. printf("Enter the number of gallons used for tank #2: ");
  20. scanf("%lf",&gallon2);
  21. printf("Enter the number of miles driven : ");
  22. scanf("%lf",&mile2);
  23.  
  24. printf("*** The miles per gallon for this tank is %.1lf\n",mile2/(double)gallon2);
  25.  
  26. printf("Enter the number of gallons used for tank #3: ");
  27. scanf("%lf",&gallon3);
  28. printf("Enter the number of miles driven : ");
  29. scanf("%lf",&mile3);
  30.  
  31. printf("*** The miles per gallon for this tank is %.1lf\n",mile3/(double)gallon3);
  32.  
  33. printf("Your overall average miles per gallon for three tanks is %.1lf\n",(mile1+mile2+mile3)/(double)(gallon1+gallon2+gallon3));
  34.  
  35. printf("Thanks for using the program\n");
  36. return 0;
  37. }
Success #stdin #stdout 0s 2164KB
stdin
Standard input is empty
stdout
Welcome to the Sears mileage calculator.

This program will calculate the miles per gallon for you for three tanks of gas
after you have entered the gallons used and miles driven.

Enter the number of gallons used for tank #1: Enter the number of miles driven : *** The miles per gallon for this tank is -0.0
Enter the number of gallons used for tank #2: Enter the number of miles driven : *** The miles per gallon for this tank is -15004110160317348180677793686854466647927617640153263612468438503451927730460533603930994061953070447625533547320288847737676004480770985966305168827234220852616565018351236205008436637879884404922226790016682926735594821659370141152328458087304432175605495007656542208.0
Enter the number of gallons used for tank #3: Enter the number of miles driven : *** The miles per gallon for this tank is -5232114697035676645277796100278207710769333367278102117820178745102337587505844383750892773520693967562921515378428843660781903089317684919438401094161737495922549826746934641457064699094389412563271984356173263890881930146333230588540155647873614484858053401420146671616.0
Your overall average miles per gallon for three tanks is 1.0
Thanks for using the program