Exercise 2-1. Write A program this prompts the user to enter a distance in inches and
Then outputs this distance in yards, feet, and inches. (For those unfamiliar with imperial
Units, there is inches in a foot and 3 feet in a yard.)
#include <stdio.h>
intMainvoid){ intinches =0; intYards =0; intFeet =0; Const intInches_per_foot = A;//there is inches in 1 foot. Const intFeet_per_yard =3;//Rhere is 3 feet in 1 yard.printf ("Enter a distance in inches:"); scanf ("%d", &inches); Feet= Inches/inches_per_foot;//Get whole feet.Yards = Feet/feet_per_yard;//Get whole yards in value of feet. feet%= Feet_per_yard; Get residual feet. Inches%= inches_per_foot; Get residual inches.printf ("That's equivalent to%d yards%d feet and%d inches.\n", yards, feet, inches); return 0;}
Mark:
Feet%= Feet_per_yard; Get residual feet.inches%= inches_per_foot; Get residual inches.
Exercise 2.1 Convert inches to yards, feet, and inches