C program for gallons that converts in cubic feet.

Q29.  Assuming that there are 7.481 gallons in a cubic foot, write a C program that asks the user to enter the number of gallons, and then displays the equivalent in cubic feet.

Ans.

#include<stdio.h>

#include<conio.h>   //for clrscr()

void main()

{

float gallon, cbft;

clrscr();  //for clear screen

printf(“\n Enter the number of gallons: “);

       scanf(“%f”,&gallon);

cbft=gallon/7.481;

printf(“\n The equivalent cubic feet is: %f”,cbft);

}

 

Output

Enter the number of gallons: 11.22

The equivalent cubic feet is: 1.499799

Leave a Reply

Your email address will not be published. Required fields are marked *

157 Views
%d bloggers like this: