Write a c++ program to add two distances in inch feet system using StructureINPUT FORMAT:Input 1: Inch1 and feet1Input 2 : Inch2 and feet2OUTPUT FORMAT:Sum of DistanceSAMPLE INPUT:234.7227.5SAMPLE OUTPUT:44'-6.7"
Answers
Answered by
0
Explanation:
I don't know if you have any questions please 24367477
Answered by
1
Answer:
#include<iostream>
using namespace std;
struct dist
{
int inch;
float feet;
};
int main()
{
struct dist d1,d2,sum;
cin>>d1.inch>>d1.feet;
cin>>d2.inch>>d2.feet;
sum.inch = d1.inch+d2.inch;
sum.feet = d1.feet+d2.feet;
if(sum.feet >=12)
{
++sum.inch;
sum.feet -=12;
}
cout<<sum.inch<<"'-"<<sum.feet<<'"';
}
Explanation:
All test cases passed.
Similar questions