pages

Saturday, 10 April 2021

program to takes two times "hour and minute" time by the user and add them and print in hour and minute time in c-programming.

 program to takes two times "hour and minute" time  by the user and add them and print in hour and minute time in c-programming.

here, we will entering the values of times by the user at two times and add them and print. 

suppose t1= 2h 36 min  t2 = 5h 56 min 

then h= 2h +5h               and m= 36 min+56min

           h= 7h                            m= 92min

 total times = h+ (92/60) :(92%60)min

total time    = 7h + 1h : 32min

total times= 8h : 32 min

                       

#include<stdio.h>
#include<conio.h>
void main()
{
   int  h1,h2,h3,h,m,m1,m2,m3;
   printf("enter the vales of the first time");
   scanf("%d %d",&h1,&m1);
   printf("\nenter the values of the second times");
   scanf("%d %d",&h2,&m2);
   m3=m1+m2;
   h=m3/60;
   m=m3%60;
   h3=h1+h2+h;
   printf("\nthe hour time is %d and minute time is %d",h3,m);
   getch();
}


output:  












No comments:

Post a Comment