Q:

Write a C program to convert a given integer (in seconds) to hours, minutes and seconds

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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\n",h,m,s);
	return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Basic Declarations and Expressions exercises

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C program to convert a given integer (in d... >>
<< Write a C program to read an amount (integer value...