Q:

Program to Convert Meter to Centimeter

belongs to collection: Miscellaneous Programs Examples

0

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

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

 

cm = 100 * meter. 

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 value of meter into cm.

#include<stdio.h>  
int main()   
{  
double meter = 40.8;  
double centimeter;  
centimeter = 100 * meter;  
printf ("Value in Centimeter is: %.2f \n", centimeter);   
return 0;  
}  

 

Output of Above C program:

Value in Centimeter is: 4080.00

 

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

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

 

Output of Above PHP program:

Value of 10 meter in Centimeter is 1000

 

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

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

 

Output of Above Java program:

Value in Centimeter is: 2000.00

 

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

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

 

Output of Above Python program:

Enter the length in meter: 25
The length in centimetre is 2500

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
Program to Convert mm to cm... >>
<< Program to Convert Feet to millimeter...