1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
//3/4/08
//WA 3 section B question 2
//
#include <stdio.h>
#include <stdlib.h>
int main ()
{
char UsrInput[255];
int gallons = 0;
int quarts = 0;
int pints = 0;
int cups = 0;
printf("please enter the a how many cups you have so it can be converted \n");
fgets(UsrInput, 255, stdin);
cups = atoi (UsrInput);
//this is the function call with the variables needing to be
//changed also in it.
liquid (gallons, quarts, pints, cups);
// this is the part that is going to display the end result has to
// be here
printf("gallons %d. \nquarts %d. \n", gallons, quarts);
printf("pints %d. \ncups %d . \n", pints, cups);
system ("pause");
return 0;
}
//liquid declaring the other variable results that will be passed back
int liquid (int g, int q, int p, int c)
{
/*doing increments becuase everytime it subtracts the total number of cups it adds one to the
total number of gallons, quarts, and pints, and also takes away from cups till the reminder is
passed back to the cups portion of the program to be displayed */
while (c > 15) {
++ g;
c = c - 16;
}
while (c > 3) {
++ q;
c = c - 4;
}
while (c > 1) {
++ p;
c = c - 2;
}
//the return of the variables that should have the information in them
return g, q, p, c;
}
|