1. Program that asks the user to enter a number of gallons, and then displays the equivalent in cubic feet.
Chapter 2:
C++ Programming Basics
Programming Exercise
Problem # 1:
Assuming there are 7.481 gallons in a cubic foot, write a program that asks the user to enter a number of gallons, and then displays the equivalent in cubic feet.
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main(){
int gallons;
float cubicFeet;
cout<<"Enter number of gallons :";
cin>>gallons;
cubicFeet=7.481*gallons;
cout<<endl<<"Cubic Feet in "<<gallons<<" gallons : "<<cubicFeet<<endl;
return 0;
}
#include<conio.h>
using namespace std;
int main(){
int gallons;
float cubicFeet;
cout<<"Enter number of gallons :";
cin>>gallons;
cubicFeet=7.481*gallons;
cout<<endl<<"Cubic Feet in "<<gallons<<" gallons : "<<cubicFeet<<endl;
return 0;
}
Code Screenshot:
Output:
Let me know in the comment section if you have any question.
Previous Post:
Program that inputs two numbers and finds whether both are equal.
Next Post:
2. Program that generates the following table using a single cout statement for all output.
2. Program that generates the following table using a single cout statement for all output.
Comments
Post a Comment