Q:

Program to Convert mm to cm

belongs to collection: Miscellaneous Programs Examples

0

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

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

 

cm = Millimeter / 10 

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

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

 

Output of Above C program:

Value of 400 millimeter in Centimeter is: 40.00

 

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

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

 

Output of Above PHP program:

Value of 10 millimeter in Centimeter is 1

 

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

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

 

Output of Above Java program:

Value in Centimeter is: 0.25

 

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

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

 

Output of Above Python program:

Enter the length in mm:1500
The length in centimeter 150.0

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