THIS PROGRAM IS TO ADD TWO DISTANCES & SHOW THEIR SUM AS NEW DISTANCE
# include
# include
typedef int dist;
struct distance
{
dist inch;
dist feet;
};
distance add(distance d1,distance d2)
{
distance temp;
temp.inch=d1.inch+d2.inch;
temp.feet=d1.feet+d2.feet;
if(temp.inch>=12)
{
temp.inch-=12;
temp.feet++;
}
return temp;
}
void main()
{
clrscr();
distance d1,d2;
distance ans;
cout<<" first enter inches & then feet in both distances "< cout<<" enter the 1st distance ";
cin>>d1.inch;
cin>>d1.feet;
cout<<" enter the 2nd distance ";
cin>>d2.inch;
cin>>d2.feet;
ans=add(d1,d2);
cout<<" new distance :-"< }