#include<stdio.h>
struct Distance{
int feet;
int inch;
}d1,d2,sum;
int main()
{
//Enter 1st distance
scanf("%d",&d1.feet);
scanf("%d",&d1.inch);
//Enter 2nd distance
scanf("%d",&d2.feet);
scanf("%d",&d2.inch);
sum.feet=d1.feet+d2.feet;
sum.inch=d1.inch+d2.inch;
sum.feet= sum.feet + sum.inch/12;
sum.inch=sum.inch%12;
printf("Sum of distances = %d feet %d inches",sum.feet,sum.inch);
return 0;
}
struct Distance{
int feet;
int inch;
}d1,d2,sum;
int main()
{
//Enter 1st distance
scanf("%d",&d1.feet);
scanf("%d",&d1.inch);
//Enter 2nd distance
scanf("%d",&d2.feet);
scanf("%d",&d2.inch);
sum.feet=d1.feet+d2.feet;
sum.inch=d1.inch+d2.inch;
sum.feet= sum.feet + sum.inch/12;
sum.inch=sum.inch%12;
printf("Sum of distances = %d feet %d inches",sum.feet,sum.inch);
return 0;
}
Input | Output | |
Test Case 1 | 40 11 10 11 | Sum of distances = 51 feet 10 inches |
Test Case 2 | 10 5 20 5 | Sum of distances = 30 feet 10 inches |
No comments:
Post a Comment