gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
Write c++ program to convert kg to pound
- User
Write c++ program to convert kg to pound
- Assistant
Here is a C++ program to convert kilograms to pounds:
#include <iostream> using namespace std; int main() { float kg, lb; cout << "Enter weight in kilograms: "; cin >> kg; lb = kg * 2.20462; cout << kg << " kilograms is equivalent to " << lb << " pounds."; return 0; }In this program:
- We declare two variables
kgandlb. - We prompt the user to enter the weight in kilograms using
coutand read the input usingcin. - We perform the conversion by multiplying
kgwith2.20462which is the conversion factor from kilograms to pounds. - We display the result using
cout.
Sample output:
Enter weight in kilograms: 60 60 kilograms is equivalent to 132.277 pounds. - We declare two variables