You are on page 1of 1

PROGRAM CODE: #include<iostream.h> #include<conio.

h> struct distance {int feet; int inches; }; void totsum(distance&l1,distance&l2); void main() { clrscr(); distance len1,len2; cout<<"enter the length1 feet\n"; cin>>len1.feet; cout<<"enter the length1 inches\n"; cin>>len1.inches; cout<<"enter the length2 feet\n"; cin>>len2.feet; cout<<"enter the length2 inches\n"; cin>>len2.inches; totsum(len1,len2); getch(); } void totsum(distance&l1,distance&l2) {distance l3; l3.feet=l1.feet+l2.feet+(l1.inches+l2.inches)/12; l3.inches=(l1.inches+l2.inches)%12; cout<<"total feet ="<<l3.feet; cout<<"\n total inches="<<l3.inches; return; }

SAMPLE OUTPUT: enter the length1 3 enter the length1 11 enter the length2 4 enter the length2 5 total feet=8 total inches=4

feet inches feet inches

You might also like