Write a program to convert seconds to hours minutes and seconds

#include<stdio.h>
int main()
   {
     int S, h, m, s;
     printf( "Second: " );
     scanf( "%d" , &S);
     h=S/3600;
     S=S%3600;
     m=S/60;
     s=S%60;
     printf("\nhh:mm:ss\n%d:%d:%d", h, m, s);
     return  0;
   }

8 comments:

  1. Write a program that obtains hours and minutes from seconds.

    ReplyDelete
  2. @shamos saqr

    s=S%60; //Don't write this statement if you no need of second in result and remove %d for s in printf funtion

    ReplyDelete
  3. Write a C program to convert minutes into hour and minutes.

    ReplyDelete