BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Program to Convert Feet to Inches in Java, C, C++, Python & PHP

Last Updated: September 14, 2022 by Chaitanya Singh | Filed Under: Programs

In this guide, we will see programs to convert length given in feet to inches in various programming languages such as Java, C, C++, Python, PHP. Feet and inches both are the unit of lengths.

Formula to Convert Feet to Inches

inches = 12 * feet

Multiply the length given in feet by 12 to get the length in inches.

Input: 2 feet
Output: 24 inches

Java Program

// Java program to convert length given in feet into inches
class JavaExample { 
  public static void main(String args []) 
  { 
    double feet = 2, inches; 
    inches = 12 * feet; 
    System.out.println(feet+ " feet = "+inches+" inches"); 
  } 
}

Output:

2.0 feet = 24.0 inches

C Program

//Write C Program to convert feet to inches
#include<stdio.h>
int main()
{
  float feet = 1.5f, inches; //declared feet and inches

  inches = 12 * feet; //feet to inches conversion

  printf ("%.2f feet = %.2f inches", feet, inches);
  return 0;
}

Output:

1.50 feet = 18.00 inches

C++ Program

// C++ Program to Convert feet to inches
#include <iostream>
using namespace std;

int main(){
  double feet, inches;

  // User is asked to enter the length in feet
  cout << "Enter the length in feet: ";
  cin >> feet;

  // converting length from feet to inches
  inches = feet * 12;

  // displaying length in inches
  cout << "The length in inches is: " << inches;
  return 0;
}

Output:
Feet to inches conversion programs

Python Program

# Python program to convert length given in feet to inches

feet = float(input("Enter the length in feet: "))

# convert feet to inches by multiplying the value in feet by 12
inches = 12 * feet;

print("The length in inches is: ",round(inches,3))

Output:

Enter the length in feet: 10
The length in inches is:  120.0

PHP Program

<?php 
// PHP program for feet to inches conversion 
$feet = .10; //length in feet
$inches = 12 * $feet; //conversion from feet to inches
echo("The length in inches is: " . $inches); 
?> 

Output:

The length in inches is: 1.2

Recommended Posts

  • Program to convert Inches to Centimetres
  • Program to Convert Inches to Feet
  • Program to Convert Kilometres to Centimetres

Top Related Articles:

  1. Program to Convert Inches to Centimetres
  2. Program to Convert Inches to Feet
  3. Program to Convert Kilometres (km) to Centimetres (cm)

Tags: Java-Conversion

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap