write a program in c++ to enter the length in centimeter and convert in to meter and kilometer
Answers
Answer:
#include<iostream>
using namespace std;
int main()
{
float km, met,cent;
cout << "\n\n Convert centimeter into meter and kilometer :\n";
cout << "--------------------------------------------------\n";
cout << " Input the distance in centimeter : ";
cin >> cent;
met = (cent/100);
km = (cent/100000);
cout << " The distance in meter is: "<< met << endl;
cout << " The distance in kilometer is: "<< km << endl;
cout << endl;
return 0;
}
Answer:
#include <iostream>
using namespace std;
int main()
{
double centi;
cout<<"Enter the value in centimetre:";
cin >> centi;
double metre = centi / 100;
double kilometre = centi / 100000;
cout <<"in metre: " << metre << " metre \n";
cout<< "in kilometre: " << kilometre << " kilometre";
return 0;
}
Explanation: