Chapter 4:
Input And Output
Programming Exercise
Problem # 18:
Write a program that inputs pounds from the user and converts it into kilograms.
Solution:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
float pound, kilogram;
cout<<"Enter pounds : ";
cin>>pound;
kilogram = 2.205 * pound; // 1kg = 2.205 * pounds
cout<<"Kilograms for "<<pound<<" pounds is : "<<kilogram<<" kilograms."<<endl;
return 0;
}
#include<conio.h>
using namespace std;
int main()
{
float pound, kilogram;
cout<<"Enter pounds : ";
cin>>pound;
kilogram = 2.205 * pound; // 1kg = 2.205 * pounds
cout<<"Kilograms for "<<pound<<" pounds is : "<<kilogram<<" kilograms."<<endl;
return 0;
}
Let me know in the comment section if you have any question.
Previous Post:
17. Program that calculates the arc of length of a convex lens by taking radius of arc and angle made by arc.
Comments
Post a Comment