Starting Vocational Training From 1-May-2024 Get Detail


Write a C program to convert a given integer (in seconds) to hours, minutes and seconds.
Test Data :
Input seconds: 25300
Expected Output:
There are:
H:M:S - 7:1:40


#include <stdio.h>
int main() {
    int sec, h, m, s;
    printf("Input 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 ",h,m,s);
    
    return 0;
}