jara

11ove11beFri, 28 Nov 2008 03:27:30 +0000 28,2008

assignment

Filed under: Uncategorized - Administrator @ 3:27 am

#include<stdio.h>

#include<conio.h>

#include <stdlib.h>

int main(){

           float gallons[5];

           int x;

           int miles[5];

           int totalM = 0;

           float total = 0;

           float totalN=0;

           float ave;

           for(x=0 ;x<5;x++){

           printf("\nEnter Gallons used(-1 to end): ");

           scanf("%f",&gallons[x]);

           if(gallons[x] == -1){

                   break;//exit

           }

           printf("Enter Miles Driven: ");

           scanf("%d",&miles[x]);

           // summation

           totalM += miles[x];

           totalN += gallons[x];

           total = miles[x] / gallons[x];

           ave = totalM / totalN;

           printf("\nThe Miles / gallon for this tank was %.6f\n",total);

           }// end of loop

           printf("\nThe Overall average miles/gallon was %.6f",ave);

           getch();

}

 

Comments »

The URI to TrackBack this entry is: http://jarah.blogsome.com/2008/11/28/assignment/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome
Theme designed by Janis Joseph