Hello everyone, I'm in an intro to programming class and look forward to using this site in the future. One issue I'm having is i need to make a function to convert gallons to liters, however, there are still some basics regarding functions and even basic programming fundamentals that I am unclear on.
I have some questions in this code that some of you might be able to answer.
1. What is "MAXCOUNT 4" what is the sole purpose of this? Why is it needed?
2. Can I take out the for(count = 1; count <= MAXCOUNT; count++)
3. I am having trouble understanding the overall structure of this function.
4. What is the purpose of %6.2f in "printf("The liters equivalent is %6.2f\n", (5.0/9.0) * (inGallons / 3.7854) );"
Code:
#include <stdio.h>
int main()
{
#define MAXCOUNT 4
void gallonsToLiters(float );
int count;
float gallons;
for(count = 1; count <= MAXCOUNT; count++)
{
printf("Enter an amount of Liquid in gallons: ");
scanf("%f", &gallons);
gallonsToLiters(gallons);
}
return 0;
}
void gallonsToLiters(float inGallons) /* function header */
{
printf("The liters equivalent is %6.2f\n", (5.0/9.0) * (inGallons * 3.7854) );
}