9. Program that inputs petrol in liters and displays how much distance the car can cover using the available petrol.
Chapter 4:
Input And Output
Programming Exercise
Problem # 9:
A car can travel 5.3 miles in 1 liter. Write a program that inputs petrol in liters and displays how much distance the car can cover using the available petrol.
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int petrol, distance;
cout<<"Enter petrol in liters : ";
cin>>petrol;
distance = 5.3 * petrol;
cout<<"Distance : "<<distance<<" miles."<<endl;
return 0;
}
#include<conio.h>
using namespace std;
int main()
{
int petrol, distance;
cout<<"Enter petrol in liters : ";
cin>>petrol;
distance = 5.3 * petrol;
cout<<"Distance : "<<distance<<" miles."<<endl;
return 0;
}
Code Screenshot:
Output:
Let me know in the comment section if you have any question.
Previous Post:
8. Program that inputs total pages of a book, number of pages a person reads in one day and number of days a person has read the book. It displays number of pages that have been read and number of pages remaining.
Comments
Post a Comment