Howdy readers, today you will learn how to write a program to convert inches to yards and feet using C Programming language.

This program prompts the user to enter the length in inches. Then, it converts the length into yards using the following factors:
- 1 Foot = 12 Inches
- 1 Yard = 36 Inches
So, without any delay, let’s begin this tutorial.
C Program to Convert Inches to Yards and Feet
C Program
// C Program to Convert Inches to Yards and Feet #include <stdio.h> int main(){ float inch, yard, feet; // Asking for input printf("Enter the length (in inches): "); scanf("%f", &inch); // Inches to Feet Conversion feet = inch / 12; // Inches to Yards Conversion yard = inch / 36; // Displaying result printf("Equivalent length (in feet): %.2f \n", feet); printf("Equivalent length (in yards): %.2f", yard); return 0; }
Output
Enter the length (in inches): 80 Equivalent length (in feet): 6.67 Equivalent length (in yards): 2.22

Explanation
float inch, yard, feet;
In the above program, we have declared three float data type variables named inch, yard, and feet.
// Asking for input printf("Enter the length (in inches): "); scanf("%f", &inch);
Then, this program prompts the user to enter the length in inches. This value gets stored in the inch named variable.
// Inches to Feet Conversion feet = inch / 12;
There are 12 inches in one foot. Therefore, we divide the total no. of inches by 12 to get the length in feet.
// Inches to Yards Conversion yard = inch / 36;
Similarly, there are 36 inches in one yard. Therefore, we divide the total no. of inches by 36 to get the length in the yard.
We can also use the factor: 1 Yard = 3 Feet for the conversion.
// Displaying result printf("Equivalent length (in feet): %.2f \n", feet); printf("Equivalent length (in yards): %.2f", yard);
At the last, the equivalent length in feet and yards is printed on the screen using printf() function. %.2f format specifier is used to limit the result to 2 decimal places.
Conclusion
I hope after reading this tutorial, you understand how to write a program to convert inches to yards and feet using C Programming language.
If you face any difficulty while understanding this program, then let us know in the comment section. We will be glad to solve your queries.