C++ Program for conversion of Kg to g. :C++ part is just simple arithmetic. What you need to understand is dimensional analysis. Since there are 1000 g per 1 kg, you can set up a conversion from g to kg by taking
xg⋅1kg1000g,
xg⋅1kg1000g,
where xx is your original mass in grams. Similarly, if you know, say, how many kg there are in one slug (the imperial unit for mass)
Convert Kilograms in Grams using C++ Program
#include<iostream>
#include<conio.h>
using namespace std;
main()
{
float kg,g;
cout<<"Please Enter the value in Kg:";cin>>kg;
cout<<"\n";
g = kg / 1000;
cout<<"The value of the g is:"<<g;
cout<<"\n";
system("Pause");
}
Output of Program
Please enter kilograms: 5
5000 Grams