Q:

Program to Convert centimeter to meter

belongs to collection: Miscellaneous Programs Examples

0

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

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

 

1m = 100 cm  

From the above formula, we have created the following formula for calculating the value in meter.

 

meter = value_in_cm/100.   

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

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

 

Output of above C program:

Value in meter is: 0.4

 

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

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

 

Output of above PHP program:

Value of 100 cm in meter is 1

 

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

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

 

Output of Java program:

Value in meter is: 0.40

 

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

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

 

Output of python program:

Enter the length in cm: 25
The length in meter 0.25

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