C++ Program to Convert Inches to Feet

In this post, we will learn how to convert inches to feet using C++ Programming language.

To convert the distance from inches to feet, we have to divide the distance in inches by 12 to obtain the distance in feet.

So, without further ado, let’s begin this tutorial.

C++ Program to Convert Inches to Feet

// C++ Program to Convert Inches to Feet
#include <iostream>
using namespace std;

int main(){
    float inches, feet;
    
    // Asking for input
    cout << "Enter the distance in inches: ";
    cin >> inches;
    
    // Conversion
    feet = inches / 12;
    
    // Displaying output
    cout << "The Distance in feet is: " << feet;
    return 0;
}

Output

Enter the distance in inches: 21
The Distance in feet is: 1.75

How Does This Program Work ?

    float inches, feet;

In this program, we have declared two float data type variables named inches and feet.

    // Asking for input
    cout << "Enter the distance in inches: ";
    cin >> inches;

Then, the user is asked to enter the distance in inches.

    // Conversion
    feet = inches / 12;

We convert inches to feet by dividing the number by 12.

    // Displaying output
    cout << "The Distance in feet is: " << feet;

Finally, the distance in feet is printed on the screen using cout statement.

Conclusion

I hope after going through this post, you understand how to convert inches to feet using C++ Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.

Also Read:

Leave a Comment

Your email address will not be published.