Q:

Program to Convert Inches to cm

belongs to collection: Miscellaneous Programs Examples

0

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

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

cm = 2.54 * inches.

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

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

 

Output:

Value in Centimeter is: 101.6

 

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

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

 

Output:

Value of 10 inches in Centimeter is: 25.4

 

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

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

 

Output:

Value in Centimeter is: 50.8 

 

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

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

 

Output:

Enter the length in Inches: 24
The length in centimeter 60.96

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