C++ program to convert a weight in pounds to kilogram

C++ program to convert pounds to kilogram:

Let’s write a program that will convert a value in pounds to kilogram in C++. This is a beginner-level program and you will learn basic C++ operations like reading user inputs, mathematical calculations and writing output to the console in C++.

This program will take the pounds as input from the user, convert it to kilogram and print it out.

Pounds to kilogram formula:

One pound is equal to 0.45359237 kilograms i.e.

``1 lb = 0.45359237 kg``

So, if we have the weight in pounds, we can multiply it with 0.45359237 to get it in kilograms.

The program will:

• Read the pounds value and assign it to a float variable.
• Multiply it with 0.45359237 to find the weight in kg.
• Print the calculated kg weight.

C++ program to convert pounds to kilograms:

Let’s write down a program to convert a pound value to kilogram:

``````#include <iostream>
using namespace std;

int main()
{
float poundToKg = 0.45359237;
float pound, kg;

cout << "Enter the weight in pound: " << endl;
cin >> pound;

kg = poundToKg * pound;
cout << pound << " lb = " << kg << " kg" << endl;
}``````

Here,

• The floating point variable poundToKg is the constant value of one pound in Kg.
• We have created two more floating point variables pound and kg to hold the pound and kg weights.
• It asks the user to enter the weight in pounds. It uses cin to assign the user-input weight to the pound variable.
• The pound value is multiplied by the poundToKg variable to find the weight in kg. This value is assigned to the kg variable.
• The last line is printing the calculated weight in kg and the user-input weight in pound.

If you run this program, it will print the output as below:

``````Enter the weight in pound:
5
5 lb = 2.26796 kg``````