Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I can\'t figure out question #8, please help. This is in the C programming langu

ID: 3665882 • Letter: I

Question

I can't figure out question #8, please help. This is in the C programming language. Thank you!

Character Strings and Formatted Input/Output to the right of the decimal. Also have the program include float.h and display the values of flt_dig and dbl_dig. Are the displayed values of 1.0/3.0 consistent with these values? Write a program that asks the user to enter the number of miles traveled and the number of gallons of gasoline consumed. It should then calculate and display the miles-per-gallon value, showing one place to the right of the decimal. Next, using the fact that one gallon is about 3.785 liters and one mile is about 1.609 kilometers, it should convert the mile- per-gallon value to a liters-per-100-km value, the usual European way of expressing fuel consumption, and display the result, showing one place to the right of the decimal. Note that the U. S. scheme measures the distance traveled per amount of fuel (higher is better), whereas the European scheme measures the amount of fuel per distance (lower is better). Use symbolic constants (using const or #def ine) for the two conversion factors

Explanation / Answer

In this program we have to first take two input from user named "miles traveled", "gallon consumed". Then we have to calculated "milesPerGallon", then we have to convert it to "liters-per-100km" according to the constant value given. C program for the same is written below:

#include<stdio.h>
#include<conio.h>

#define kmInOneMiles 1.609  
#define literInOneGallon 3.785

void main()
{
    float mileTraveled,gallonConsumed, milesPerGallon, literPerHundredKm;

    printf("Enter the number of miles traveled ");
    scanf("%f", &mileTraveled);
    printf("Enter the number of gallons of gasoline consumed ");
    scanf("%f", &gallonConsumed);

    milesPerGallon = mileTraveled/gallonConsumed;
    printf("MilesPerGallon is = %f ", milesPerGallon );
  
   literPerHundredKm = ((literInOneGallon*100)/(milesPerGallon*kmInOneMiles));
  
   printf("literPerHundredKm is = %f ", literPerHundredKm);
          
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote