Signup/Sign In
LAST UPDATED: SEPTEMBER 6, 2021

Convert Centimetre to Feet and Inches

    In this tutorial, we will see how to convert a given value in centimeters to feet and inches.

    Here, we are given a value in centimeters and our task is to convert that value to inches and feet. As we know, 1 inch is equal to 2.54 centimeter, so 1 centimeter is equal to 0.3937 inches( as 1/2.54 = 0.3937). So, n centimeter is equal to n*0.3937 inches.

    Similarly, 1 foot is equal to 30.48 centimeter, therefore, 1 centimeter is equal to 0.0328 feet( 1/30.48 = 0.0328). So, n centimeter is equal to n*0.0328 foot.

    Let us look at the below examples for a better understanding of the above logic.

    Java program to convert centimeter to Feet and Inches

    In this program, we will see how to convert a given value in centimeters to feet and inches in java.

    Algorithm:

    1. Start

    2. Create an instance of the Scanner class.

    3. Declare a variable to store the value in centimeters.

    4. Ask the user to initialize this variable.

    5. Call a user-defined method to convert the value to inches and feet.

    6. In order to convert the value into inches, multiply the given value in centimeter with 0.3937

    7. In order to convert the value into feet, multiply the given value in centimeter with 0.0328

    8. Display the result in inches.

    9. Display the result in feet.

    10. Stop.

    Let us look at the below example for a better understanding of the above algorithm.

    // Java program to convert a value in centimeter to Feet and Inches
    import java.io.*;
    import java.util.Scanner;
    public class Main 
    {
    	// User-definned Method to convert centimeter to inches
    	static double convertToInches(int cm)
    	{
    		double inch = 0.3937 * cm;
    		double feet = 0.0328 * cm;
    		System.out.printf("Value in inches is: %.2f \n", inch);
    		System.out.printf("Value in feet is: %.2f", feet);
    		return 0;
    	}
    	// Driver Code
    	public static void main(String args[])
    	{
    	    //Create instance of the Scanner class
    	    //Take input from the user
    	    Scanner sc=new Scanner(System.in);
            System.out.println("Enter the Value in centimeter: ");
    		int cm = sc.nextInt();
    		//Calling a user-defined method
    		convertToInches(cm);
    	}
    }
    


    Enter the Value in centimeter: 123
    Value in inches is: 48.43
    Value in feet is: 4.03

    C program to convert centimeter to Feet and Inches

    In this program, we will see how to convert a given value in centimeters to feet and inches in C.

    Algorithm:

    1. Start

    2. Declare a variable to store the value in centimeters.

    3. Ask the user to initialize this variable.

    4. Call a user-defined function to convert the value to inches and feet.

    5. In order to convert the value into inches, multiply the given value in centimeter with 0.3937

    6. In order to convert the value into feet, multiply the given value in centimeter with 0.0328

    7. Display the result in inches.

    8. Display the result in feet.

    9. Stop.

    Let us look at the below example for a better understanding of the above algorithm.

    // C program to convert a value in centimeter to Feet and Inches
    #include <stdio.h>
    
    // Function to convert centimeter to inches 
    double convertToInches(int cm) 
    {
    	double inch = 0.3937 * cm;
    	double feet = 0.0328 * cm;
    	printf ("Value in inches is: %.2f \n", inch);
    	printf ("Value in feet is: %.2f", feet);
    	return 0;
    }
    // Driver Code
    int main() 
    {
        printf ("Enter the value in centimeter: \n");
    	int cm;
    	scanf("%d",&cm);
    	convertToInches(cm);
    	return 0;
    }
    


    Enter the value in centimeter: 432
    Value in inches is: 170.08
    Value in feet is: 14.17

    C++ Program to convert centimeter to Feet and Inches

    In this program, we will see how to convert a given value in centimeters to feet and inches in C++.

    Algorithm:

    1. Start

    2. Declare a variable to store the value in centimeters.

    3. Ask the user to initialize this variable.

    4. In order to convert the value into inches, multiply the given value in centimeter with 0.3937

    5. In order to convert the value into feet, multiply the given value in centimeter with 0.0328

    6. Display the result in inches.

    7. Display the result in feet.

    8. Stop.

    Let us look at the below example for a better understanding of the above algorithm.

    //C++ Program to convert a value in centimeter to inches and feet
    #include<iostream>
    using namespace std;
    int main()
    {
        float cm;
        cout<<"Enter the value in centimeters: "<<endl;
        cin>>cm;
        double inch = 0.3937 * cm;
    	double feet = 0.0328 * cm;
        cout<<"Value in inches is equals to "<<inch<<endl;
        cout<<"Value in feet is equals to "<<feet<<endl;
        return 0;
    }


    Enter the value in centimeter: 239
    Value in inches is equals to 94.0943
    Value in feet is equals to 7.8392

    Conclusion:

    In this tutorial, we saw how to convert a value in centimeters to inches and feet by using three different programming languages.

    You may also like:

    I am the founder of Studytonight & Fullstack developer (MERN). I like writing content about ReactJS, MERN, JavaScript, Docker, Linux, PHP, Go lang, Cloud, Web development, and general Tech related content. I have 10 years of diverse experience in software development.
    IF YOU LIKE IT, THEN SHARE IT
    Advertisement

    RELATED POSTS