In this guide, we will see **programs to convert Kilometres to Centimetres** in various programming languages such as Java, C, C++, Python, PHP. The kilometres and centimetres both are the unit of lengths.

## Formula to convert Kilometres to Centimetres

cm = km * 100000

Multiply the km by 100000 to get the length in cm.

Input: .5 km Output: 50000 cm

## Java Program

// Java program to convert length given in Kilometres into centimetres class JavaExample { public static void main(String args []) { double km = 2; double cm; cm = 100000 * km; System.out.println(km+ "km = "+cm+" cm"); } }

**Output:**

2.0km = 200000.0 cm

## C Program

#include<stdio.h> int main() { double km = 3, cm; //kilometres to centimetres conversion cm = 100000 * km; printf ("3 kilometres = %.2f centimetres", cm); return 0; }

**Output:**

3 kilometres = 300000.00 centimetres

## C++ Program

// C++ Program to Convert kilometres to centimetres #include <iostream> using namespace std; int main(){ double km, cm; // User is asked to enter the length in kilometres cout << "Enter the length in kilometres: "; cin >> km; // converting length from km to cm cm = km * 100000; // displaying length in centimetres cout << "The length in centimetre is: " << cm; return 0; }

**Output:**

Enter the length in kilometres: 1.5 The length in centimetre is: 150000

## Python Program

# Python program to convert length given in km to cm km = float(input("Enter the length in kilometres: ")) # convert km to cm by multiplying the value in km by 100000 cm = 100000 * km; print("The length in centimetre is: ",round(cm,3))

**Output:**

Enter the length in kilometres: .25 The length in centimetre is: 25000.0

## PHP Program

<?php // PHP program for kilometres to centimetres conversion $km = 5.5; //length in kilometres $cm = 100000 * $km; //conversion from km to cm echo("The length in centimetres is: " . $cm); ?>

**Output:**

The length in centimetres is: 550000