Q:

Program to Convert cm to Feet and Inches

belongs to collection: Miscellaneous Programs Examples

0

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

Following are the two formulas which help to convert cm to feet and inches:

  1. 1 inch = 2.54 centimeter
  2. 1 feet = 30.48 centimeter

From these formulae, we find the following two formulas:

  1. inch = 0.3937 * Centimeter (cm)
  2. feet = 0.0328 * Centimeter (cm)

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 cm to feet and inches.

#include<stdio.h>  
int main()   
{  
int centimeter = 40;  
double inch, feet;  
inch = 0.3937 * centimeter;  
feet = 0.0328 * centimeter;  
printf ("Inches is: %.2f \n", inch);   
printf ("Feet is: %.2f", feet);   
return 0;  
} 

 

 

Output:

Inches is: 15.75 
Feet is: 1.31

 

Program 2: Write a Program in PHP for converting the cm to feet and inches.

<?php   
// This is a PHP program which converts the centimeter length to feet and Inches   
$cen = 10;   
$inch = 0.3937 * $cen;   
$feet = 0.0328 * $cen;   
echo("Inches is: " . $inch . "\n");   
echo("Feet is: " . $feet);    
?>   

 

Output:

Inches is: 3.94 
Feet is: 0.33

 

Program 3: Write a Program in Java for converting cm to feet and inches.

// This is a Java program which converts centimeter length to feet and Inches   
import java.io.*;   
class convert {   
static double Conversion_length(int centimeter)   
{   
double inch, feet;  
inch  = 0.3937 * centimeter;   
feet = 0.0328 * centimeter;   
System.out.printf("Inches is: %.2f \n", inch);   
System.out.printf("Feet is: %.2f", feet);   
return 0;   
}    
public static void main(String args [])   
{   
int centimeter = 20;   
Conversion_length(centimeter);   
}  
}  

 

Output:

Inches is: 7.87
Feet is: 0.656

 

Program 4: Write a Program in Python for converting cm to feet and inches.

# This is a Python program which converts centimeter length to feet and Inches   
      
centimeter=int(input("Enter the height in centimeters:"))  
#convert centimeter to inches  
inches = 0.394 * centimeter  
#convert centimeter to feet  
feet = 0.0328 * centimeter  
     
print("The length in feet",round(feet,2))  
print("The length in inches",round(inches,2))  

Output:

Enter the height in centimeters: 167
The length in feet 5.48
The length in inches 65.8

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