Question
Write a program that prompts the user for a number of seconds-assume that the user enters a non-negative integer value. Calculate and output the equivalent number of hours, minutes and seconds. A sample session should look something like this, with appropriate values calculated and output. Assignment 1, part b) for your name Please enter the number of seconds: 5678 5678 seconds is hours, minutes and seconds. Required Documentation and Style for All Programs. See Assignment la Other requirements: In this program, all values are int.
Explanation / Answer
#include int main() { int input,hour,min,sec; int temp; printf("enter the number of seconds"); scanf("%d",&input); temp=input/3600; hour=temp; input=input-hour*3600; min=input/60; sec=input-min*60; printf("%d hours,%d minutes,%d seconds",hour,min,sec); }