C program to read time in seconds and convert in time format using class

#include<stdio.h>
#include<conio.h>
void main() {
int sec, h, m, s;
printf("Enter time in seconds: ");
scanf("%d", &sec);
h = (sec/3600);
m = (sec -(3600*h))/60;
s = (sec -(3600*h)-(m*60));
printf("H:M:S - %d:%d:%d\n",h,m,s);
getch();
}

 

Output:

C program to read time in seconds and convert in time format using class

Leave a Reply

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