Q:

Program to Convert Kilometer to cm

belongs to collection: Miscellaneous Programs Examples

0

Here, we will learn how to convert the length value, which is given in Kilometer, to the length in centimeter.

If we want to convert the value of Kilometer into cm value, then we have to use the following formula:

1 km = 100000 cm. cm = 100000 * Kilometer.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program 1: Write a Program in C for converting the length value of Kilometer into centimeter.

#include<stdio.h>  
int main()   
{  
double Kilometer = 4;  
double centimeter;  
centimeter = 100000 * Kilometer;  
printf ("Value of 4 kilometer in Centimeter is:", centimeter);   
return 0;  
}  

 

Output:

Value of 4 kilometer in Centimeter is: 400000

 

Program 2: Write a Program in PHP for converting the value of Kilometer into cm.

<?php   
// This is a PHP program which converts the value of Kilometer into the value of cm   
$Kilometer = 10.4;   
$centimeter = 100000 * $Kilometer;   
echo("Value of 10.4 Kilometer in Centimeter is " . $centimeter . "\n");   
?>   

 

Output:

Value of 10.4 Kilometer in Centimeter is: 1040000

 

Program 3: Write a Program in Java for converting the value of Kilometer into cm.

// This is a Java program which converts the value of Kilometer into the value in cm   
import java.io.*;   
class convert {   
static double Conversion_Kilometer_to_cm(int Kilometer)   
{   
double centimeter;  
centimeter  = 100000 * Kilometer;    
System.out.printf("Value in Centimeter is: %.2f \n", centimeter);   
return 0;   
}    
public static void main(String args [])   
{   
int Kilometer = 2.008457;   
Conversion_Kilometer_to_cm(Kilometer);   
}  
}  

 

Output:

Value in Centimeter is: 200845.70

 

Program 4: Write a Program in Python for converting the value of Kilometer into cm.

# This is a Python program which converts the value of Kilometer into cm   
      
Kilometer=int(input("Enter the length in Kilometer:"))  
#convert Kilometer to cm  
centimeter  = 100000 * Kilometer;    
     
print("The length in centimeter",round(centimeter,2))  

 

Output:

Enter the length in Kilometer: 25
The length in centimeter 2500000.00

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Miscellaneous Programs Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Pyramid Programs in VB (Visual Basic)... >>
<< Program to Convert Inches to Feet...