Convert Seconds to Hours, minutes and Seconds - C/C++

 



A Simple C Program to convert Seconds to Hours, Minutes and Seconds.



#include<stdio.h>
#include<conio.h>
void main()
{
    int sec=0,min=0,hour=0;
    clrscr();
    printf("Enter Seconds -> ");
    scanf("%d",&sec);
    if(sec>59)
    {
        min=sec/60;
        sec=sec%60;
    }
    if(min>59)
    {
        hour=min/60;
        min=min%60;
    }
    printf("\n\n %d Hours  %d Minutes  %d Seconds",hour,min,sec);
    getch();
}

Post a Comment