If you do not know, 12 inches is 1 foot.
Program to add two distances in the inch-feet system
Output
Enter 1st distance Enter feet: 23 Enter inch: 8.6 Enter 2nd distance Enter feet: 34 Enter inch: 2.4 Sum of distances = 57'-11.0"
In this program, a structure Distance is defined. The structure has two members:
- feet - an integer
- inch - a float
Two variables d1 and d2 of type struct Distance are created. These variables store distances in the feet and inches.
Then, the sum of these two distances are computed and stored in the result variable. Finally, result is printed on the screen.