Sunday, May 8, 2016

Convert Seconds into Hours , Minutes and Seconds

Write a C code That Take From The User Number Of Seconds Then Convert it to Hours, Minutes and Seconds.


#include <stdio.h> 
#include <Stdlib.h>

int  main ()
{
    int num, min, sec, hr;

    printf ( "Enter Number Of Seconds: \ n " );
    scanf ( "% d" , & num);

    min = num /  60 ;
    sec = num %  60 ;

    if (min >  60 ) {
        hr = min / 60 ;
        min = min % 60 ;
        printf ( "% d Hours:% d Minutes: Seconds% d \ n " , hr, min, sec);
    }
    else   
        printf ( "% d Minutes: Seconds% d" , min, sec);
       return  0 ;
}





Share this

0 Comment to "Convert Seconds into Hours , Minutes and Seconds"

Post a Comment