Program to convert Centimeter to Feet and Inches - GeeksforGeeks

04 Feb, 2022
In this article, we will learn how to convert Height, given in centimeter to Height in feet and inches. Examples:  
Input : centimeter = 10
Output : inches = 3.94
         feet = 0.33

Input : centimeter = 85
Output : inches = 33.46
         feet = 2.79
 
We know that 1 inch is equal to 2.54 centimeters, so 1 centimeter is equal to 0.3937 inches. Therefore, n centimeters are equal to (n * 0.3937)inches. We also know that 1 foot is equal to 30.48 centimeters, therefore, 1 centimeter is equal to 0.0328 feet. So, n centimeters are equal to (n * 0.0328)feet. 
 
C++
Java
Python3
C#
PHP
Javascript
// C++ program to convert Centimeter to Feet and Inches#include <iostream>using namespace std; // Function to perform conversionvoid conversion(int centimeter){    double inches = 0.3937 * centimeter;    double feet = 0.0328 * centimeter;       // Printing the output    cout << "Inches is: " << inches << "\n";    cout << "Feet is: " << feet<< "\n";} // Driver Codeint main(){    int centimeter = 10;    conversion(centimeter);}  /*This code is contributed by Gunjan Gupta.*/
// Java program to convert// centimeter to feet and Inchesimport java.io.*; class GFG {     // Function to perform conversion    static double Conversion(int centi)    {        double inch = 0.3937 * centi;        double feet = 0.0328 * centi;        System.out.printf("Inches is: %.2f \n", inch);        System.out.printf("Feet is: %.2f", feet);        return 0;    }     // Driver Code    public static void main(String args[])    {        int centi = 10;        Conversion(centi);    }} /*This code is contributed by Nikita Tiwari.*/
# Python program to convert centimeter to feet and# Inches Function to perform conversiondef Conversion(centi):    inch = 0.3937 * centi    feet = 0.0328 * centi    print ("Inches is:", round(inch, 2))    print ("Feet is:", round(feet, 2)) # Driver Codecenti = 10Conversion(centi)
// C# program to convert// centimeter to feet and Inchesusing System; class GFG {     // Function to perform conversion    static double Conversion(int centi)    {        double inch = 0.3937 * centi;        double feet = 0.0328 * centi;        Console.WriteLine("Inches is: " + inch);        Console.WriteLine("Feet is: " + feet);        return 0;    }     // Driver Code    public static void Main()    {        int centi = 10;        Conversion(centi);    }} // This code is contributed by vt_m.
<?php// PHP program to convert// centimeter to feet and Inches // Function to perform conversionfunction Conversion($centi){    $inch = 0.3937 * $centi;    $feet = 0.0328 * $centi;    echo("Inches is: " . $inch . "\n");    echo("Feet is: " . $feet);} // Driver Code$centi = 10;Conversion($centi); // This code is contributed by Ajit.?>
<script>//Program to convert centimeter to feet and Inches // Function to perform conversion      function Conversion(centi) {     var inch = 0.3937 * centi;     var feet = 0.0328 * centi;      inch=inch.toFixed(2);      feet=feet.toFixed(2);    document.write("Inches is: \n" + inch + "<br>");    document.write("Feet is: " + feet);     return 0;} // Driver Code     centi = 10;          Conversion(centi); //This code is contributed by simranarora5sos</script>
Output:  
Inches is: 3.94 
Feet is: 0.33
 
jit_t
simranarora5sos
gunjang12
School Programming
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Interfaces in Java
Operator Overloading in C++
Overriding in Java
Types of Operating Systems
Python program to check if a string is palindrome or not
Friend class and function in C++
Polymorphism in C++
Inheritance in Java
Constructors in Java
Different ways of Reading a text file in Java