source file name: timestruct.C

#include <stdio.h>


struct time

{

int h,m,s;

};

int  main()

{

int hrs,min,sec;

struct time t1={10,45,35};

struct time t2={14,30,25};

//clrscr();

if(t2.s>t1.s)

{

sec=t2.s-t1.s;

}

else

{

sec=t2.s+60-t1.s;

t2.m=t2.m-1;

}

if(t2.m>t1.m)

{

min=t2.m-t1.m;

}

else

{

min=t2.m+60-t1.m;

t2.h=t2.h-1;

}

hrs=t2.h-t1.h;

printf("time difference\nh=%d\nm=%d\ns=%d",hrs,min,sec);

//getch();

return 0;

}

Output:

Time difference

H=3

M=44

S=50