The Program in C++ to enter length in cm,convert into meter and kilometer is given below:
#include <iostream>
using namespace std;
int main() {
double cm, m, km;
cout << "\n\n Convert centimeter into meter and kilometer :\n";
cin>>cm;
m = cm / 100;
km = cm / 100000;
cout << cm << " centimeters is equal to " << m << " meters and " << km << " kilometers.";
return 0;
}
Output:
Convert centimeter into meter and kilometer :
1
1 centimeters is equal to 0.01 meters and 1e-05 kilometers.
Pro-Tips💡
This program uses the iostream
library to handle input and output,
and defines the main function that is executed when the program runs.
Inside the main function, it declares 3 double variables cm,m,km.
Then it prompts the user to enter the length in cm.
Then it converts cm to meters and km. Finally it prints the result of conversion.
Learn C-Sharp ↗
C-sharp covers every topic to learn about C-Sharp thoroughly.
Learn C Programming ↗
C-Programming covers every topic to learn about C-Sharp thoroughly.
Learn C++ Programming↗
C++ covers every topic to learn about C-Sharp thoroughly.