\* C program to add two distances in feet and inches using structure *\
# include < stdio.h >
# include < conio.h >
struct distance
{
int feet ;
int inch ;
} ;
void addDistance( struct distance d1,struct distance d2 )
{
struct distance d3 ;
d3.feet = d1.feet + d2.feet ;
d3.inch = d1.inch + d2.inch ;
d3.feet = d3.feet + d3.inch/12 ;
d3.inch = d3.inch%12 ;
printf("\n Total distance - Feet: %d, Inches: %d",d3.feet,d3.inc ) ;
}
int main( )
{
struct distance d1, d2 ;
printf("\n Enter first distance !" ) ;
printf("\n First distance feet :" ) ;
scanf("%d", &d1.feet ) ;
printf(" First distance inches :" ) ;
scanf("%d", &d1.inch ) ;
printf("\n Enter second distance ! " ) ;
printf("\n second distance feet :" ) ;
scanf("%d", &d2.feet ) ;
printf(" second distance inches :" ) ;
scanf("%d", &d2.inch ) ;
addDistance( d1, d2 ) ;
return 0 ;
}