# Write a Program to convert given inches into equivalent yard, and feet

By | October 6, 2021

In this article, we will write a program that can accept length in inches and convert it to the corresponding yard, and foot.

The program can be made using simple arithmetic operations. If we look at the length converter there are 36 inches in 1 yard and 12 inches in 1 foot.

Now let’s write our program that will convert the given inches into equivalent yards and foot.

## C Program to convert given inches into the equivalent yard, and feets

```#include <stdio.h>

int main()
{
float inch, foot, yard;

printf("Enter Inches: ");
scanf("%f", &inch);

//convert inches into yards
yard = inch/36;
//convert inches into feet
foot = inch/12;

printf("There are %.2f yard(s) in %.2f inch(es)\n", yard, inch);
printf("There are %.2f foot in %.2f inch(es)\n", foot, inch);

return 0;
}```

Output

```Enter Inches: 12
There are 0.33 yard(s) in 12.00 inch(es)
There are 1.00 foot in 12.00 inch(es)```

## C++ Program to convert given inches into the equivalent yard, and feets

```#include <iostream>
using namespace std;

int main()
{
float inch, foot, yard;

cout<<"Enter Inches: "; cin>>inch;

//convert inches into yards
yard = inch/36;
//convert inches into feet
foot = inch/12;

cout<<"There are "<<yard<<" yard(s) in "<<inch<<" inch(es)\n";
cout<<"There are "<<foot<<" foot in " <<inch<<" inch(es)\n";

return 0;
}```

Output

```Enter Inches: 13
There are 0.361111 yard(s) in 13 inch(es)
There are 1.08333 foot in 13 inch(es)```

## Python Program to convert given inches into the equivalent yard, and feets

```inch = int(input("Enter Inches: "))

# convert inches into yards
yard = inch/36
# convert inches into feet
foot = inch/12

print(f"There are {round(yard,4)} yard(s) in {inch} inch(es)")
print(f"There are {round(foot,4)} foot in {inch} inch(es)")
```

Output

```Enter Inches: 23
There are 0.6389 yard(s) in 23 inch(es)
There are 1.9167 foot in 23 inch(es)
```

## Complexity Analysis

• Time Complexity: O(1), constant time complexity.
• Space Complexity: O(1), constant space complexity

## Conclusion

In this programming tutorial, we learned how to convert user-entered inches into yards and feet, using C, C++, and Python programming languages. The program is quite straightforward and works on simple arithmetic operations.

If you like this article or have any suggestions please let us know by commenting down below.