In this guide, we will see programs to convert inches to feet in various programming languages such as Java, C, C++, Python, PHP. The inches and feet are the unit of lengths.
Formula to convert Inches to Feet
feet = inches / 12
Divide the value in inches by 12 to get the length in feet unit.
Input: 120 inches Output: 10 feet
Java Program
class JavaExample { public static void main(String args[]) { double inches, feet; inches = 120; //inches to feet conversion feet = inches/12; System.out.println(inches + " inches = "+feet+" feet"); } }
Output:
120.0 inches = 10.0 feet
C Program
// C program to convert Inches to Feet #include<stdio.h> int main() { double inches = 24, feet; feet = inches / 12; printf ("%.2f inches = %.2f feet", inches, feet); return 0; }
Output:
24.00 inches = 2.00 feet
C++ Program
// C++ Program to Convert Inches to Feet #include <iostream> using namespace std; int main(){ double inches, feet; // User is asked to enter the length in inches cout << "Enter the length in inches: "; cin >> inches; // converting from inches to feet feet = inches / 12; // displaying length in feet cout << "The length in feet is: " << feet; return 0; }
Output:
Enter the length in inches: 60 The length in feet is: 5
Python Program
# Python program to convert the length given in inches to feet inches = int(input("Enter the length in inches:")) # Converting the entered length in inches to feet unit feet = inches / 12; print("The length in feet is: ",round(feet,2))
Output:
Enter the length in inches: 120 The length in feet is: 10.0
PHP Program
<?php // PHP program to convert the length given in inches to feet $inches = 36; $feet = $inches/12; echo("36 inches in feet is: " . $feet . "\n"); ?>
Output:
36 inches in feet is: 3
Previous: Program to convert Inches to Centimetres