Write a program to enter length in centimeter and convert it into meter and kilometer, and also convert the same into Equivalents
Write a program to enter length in centimeter and convert it into meter and kilometer, and also convert the same into Equivalents
Share
Solution In C++
#include <iostream> using namespace std; int main(){ // declaraing the variables to take input // and to store the values in "m" and "km" double length_cm; double length_m; double length_km; cout<<"Convert centimeter into meter and kilometer : \n"; cout<<"------------------------------------------- \n"; cout<<"Input the distance in centimeter : "; // Taking the input in centimeter cin>>length_cm; // calculating the length in m // as 1m = 100 cm length_m = length_cm/100; // calculating the length in km // using meter length calculated above // as 1km = 1000 m length_km = length_m/1000; //printing the length in meter and kilometer cout<<"The distance in meter is: "<<length_m<<"\n"; cout<<"The distance in kilometer is: "<<length_km<<"\n"; }Vote up the answer and show some support
cm = input("Enter Length in Centimeter : "); meter = float(cm)/100; kilometer = float(cm) / 100000; print("Length in meter = " ,meter , "m"); print("Length in Kilometer = ",kilometer , "km");