In C++: Write a function that takes inputs of quarts and pints (whole numbers),
ID: 1928344 • Letter: I
Question
In C++:Write a function that takes inputs of quarts and pints (whole numbers), then calculates and returns an output of the total number of gallons (a floating-point value). There are 4 quarts in a gallon, and 2 pints in a quart. Use appropriate parameter passing and return mechanisms. Use appropriate datatypes. For example, with inputs of 4 quarts and 4 pints, the result would be 1.5 gallons. Use proper code formatting techniques. Do not write a main routine. Your function does not do cin or cout.
Explanation / Answer
main() int q,p float result; printf("enter quarts"); scanf("%d",&q); printf("enter pints")' scanf("%d",&p); result=(4/q)+(2/p); printf("total gallons is %f",result); getch(); }