Javascript Program to Enter the Length in Centimeter and Convert it into Meter & Kilometer
ADVERTISEMENTS
Javascript program to enter the length in centimeter and convert it into meter and kilometer. In this article, you will learn how to convert the centimeter into meter and kilometer in javascript language.
Conversion Formula
1m = 100cm
1km = 100000cm
Source Code
<!-- Javascript Program to Enter the Length in Centimeter and Convert it into Meter & Kilometer -->
<script type="text/javascript">
var c, m, k;
// c = centimeter
// m = meter
// k = kilometer
/* Convert centimeter into meter and kilometer */
c = 10000
m = c/100;
k = c/10000;
document.write("Lenth in meter = " + m + " meter<br />");
document.write("Lenth in kilometer = " + k + " kilometer");
</script>
Output
Lenth in meter = 100 meter
Lenth in kilometer = 1 kilometer