This program convert a value of some unit (g, kg, mg) into other unit.
#include<iostream>
#include<conio.h>
using namespace std;
float n, a, b, c, d, e,g=1 ,mg, kg;
int i, j;
int main()
{
cout << " This a programe to convert the unit of some value \n \n put some value = ";
cin >> n;
cout << "Now put it's present unit \n \n 1 for 'g' \n 2 for 'kg' \n 3 for 'mg' \n \n ";
cin >> i;
//a = n * i;
// cout << a<<" g";
switch (i)
{
case 1:
cout <<" ="<< n << " g";
a = n;
break;
case 2:
cout <<" ="<< n << " kg";
a = n * 1000;
break;
case 3:
cout <<" ="<< n << " mg";
a = n / 1000;
break;
}
cout << "\n \n Now put the unit in which you want to convert your value \n \n 1 for 'g' \n 2 for 'kg' \n 3 for 'mg' \n \n ";
cin >> j;
switch (j){
case 1:
cout << " =" << a << " g";
break;
case 2:
cout << " =" << a / 1000 << " kg";
break;
case 3:
cout << " =" << a * 1000 << " mg";
break;
}
_getch();
}
#include<iostream>
#include<conio.h>
using namespace std;
float n, a, b, c, d, e,g=1 ,mg, kg;
int i, j;
int main()
{
cout << " This a programe to convert the unit of some value \n \n put some value = ";
cin >> n;
cout << "Now put it's present unit \n \n 1 for 'g' \n 2 for 'kg' \n 3 for 'mg' \n \n ";
cin >> i;
//a = n * i;
// cout << a<<" g";
switch (i)
{
case 1:
cout <<" ="<< n << " g";
a = n;
break;
case 2:
cout <<" ="<< n << " kg";
a = n * 1000;
break;
case 3:
cout <<" ="<< n << " mg";
a = n / 1000;
break;
}
cout << "\n \n Now put the unit in which you want to convert your value \n \n 1 for 'g' \n 2 for 'kg' \n 3 for 'mg' \n \n ";
cin >> j;
switch (j){
case 1:
cout << " =" << a << " g";
break;
case 2:
cout << " =" << a / 1000 << " kg";
break;
case 3:
cout << " =" << a * 1000 << " mg";
break;
}
_getch();
}
No comments:
Post a Comment