PROGRAM TO FIND THE LENGTH USING CPP
#include<conio.h>
#include<iostream.h>
struct length
{
int feet;
int inch;
};
void main()
{
struct length l1,l2,l3;
clrscr();
length add(length,length);
cout<<"enter
length(feet/inch):";
cin>>l1. feet >>
l1. inch;
cout<<"enter
length(feet/inch):";
cin>>l2. feet>>
l2. inch;
l3=add(l1,l2);
cout<<"the length
is : "<<l3. feet<<":"<<l3.
inch<<"\" ";
getch();
}
length add(length x,length y)
{
length l4;
l4.feet =
x.feet+y.feet+(x.inch+y.inch)/12;
l4.inch = (x.inch+y.inch)%12;
return l4;
}
OUTPUT:
enter length(feet/inch) : 5
12
enter length(feet/inch) : 2
12
the length is : 9:0"
No comments: