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.)
//ME#include <stdio.h>intMain () {intinches; intfeet; intyards; printf ("Please enter the distance in inches:"); scanf ("%d", &inches); Feet= inches/ A; Yards= Feet/3; Feet= Feet%3; Inches= inches% A; printf ("the dis tance is%d yards,%d feet,%d inches", yards, feet, inches); return 0;}
//Exercise 2.1 Convert inches to yards, feet, and inches#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;}
Exercise 2-1.