I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.
#include <stdio.h> struct Distance { int feet; float inch; } d1, d2, sum_of_Distances; int main() { printf("Enter information for 1st distance\n"); printf("Enter feet: "); scanf("%d", &d1.feet); printf("Enter inch: "); scanf("%f", &d1.inch); printf("\nEnter information for 2nd distance\n"); printf("Enter feet: "); scanf("%d", &d2.feet); printf("Enter inch: "); scanf("%f", &d2.inch); sum_of_Distances.feet = d1.feet+d2.feet; sum_of_Distances.inch = d1.inch+d2.inch; if (sum_of_Distances.inch>12.0) { sum_of_Distances.inch = sum_of_Distances.inch-12.0; ++sum_of_Distances.feet; } printf("\nSum of distances = %d\'-%.1f"",sum_of_Distances.feet, sum_of_Distances.inch); return 0; }
Enter information for 1st distance
Enter feet: 5
Enter inch: 12
Enter information for 2nd distance
Enter feet: 6
Enter inch: 5
Sum of distances = 12'-5.0"
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your availability.
Result:
Enter information for 1st distance
Enter feet: 5
Enter inch: 12
Enter information for 2nd distance
Enter feet: 6
Enter inch: 5
Sum of distances = 12'-5.0"
need an explanation for this answer? contact us directly to get an explanation for this answer