Skip to content

Instantly share code, notes, and snippets.

@faisal95bd
Last active April 13, 2022 07:20
Show Gist options
  • Save faisal95bd/322d09169d2e366d298def6b14f9348f to your computer and use it in GitHub Desktop.
Save faisal95bd/322d09169d2e366d298def6b14f9348f to your computer and use it in GitHub Desktop.
Convert time given in seconds to hours, minutes and seconds
#include<stdio.h>
int main() {
int sec, hh, mm, ss;
printf("Enter time in seconds: ");
scanf("%d", & sec);
hh = sec / 3600;
mm = (sec - hh * 3600) / 60;
ss = sec - hh * 3600 - mm * 60;
printf("%d seconds = %d hour %d minute %d second", sec, hh, mm, ss);
return (0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment