URI Online Judge Solution| 1019 Time Conversion

Input format=integer
Output format=hours:minutes:seconds
Solution:
1 minute =60 second
1hour = 60minute

1min = 60 second
60 min = 60*60=3600 seconds

3600 second=1hour
1 second=1/3600 hour
556 second=556*1/3600 hour

3600 second =60 minute
1 second = 60/3600 minute
556 second = 60/3600 * 556 minute
Here, in this case in finding minute we also have to use remainder because it is the portionate part of hour so the formula will be n%3600*60

556 second = 556 % 60 because second is the part of seconds and we want to find out the seconds so in this case we have to use remainder

#include<iostream>
#include<cstdio>
int main(){
int n,h,m,s;
scanf("%d",&n);
h=n/3600;
m=n%3600/60;
s=n%60;
printf("%d:%d:%d\n",h,m,s);
return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *