
- Forum
- Programming Talk
- C and C++
- C program to convert seconds to hours and mins
C program to convert seconds to hours and mins
This is a discussion on C program to convert seconds to hours and mins within the C and C++ forums, part of the Programming Talk category; -Given as input an integer number of seconds, print as output the equivalent time in hours, min, sec. 7322 second ...
-
C program to convert seconds to hours and mins
-Given as input an integer number of seconds, print as output the equivalent time in hours, min, sec.
7322 second sis equivalent to 2 hrs 2 min 2 sec.
PLS HELP im new in programming... thanks GOD BLESS!!!
Last edited by admin; 03-28-2011 at 03:29 PM.
-
12-16-2010, 12:47 PM #2
- Join Date
- Dec 2010
- Answers
- 32
Include this step in your programming.
Suppose your input is n sec n output is h hr m min s sec.
Then h = n/3600
x = n%3600
m = x/60
s = x%60
Print h hrs m min s sec as output
-
03-28-2011, 01:13 PM #3Code:
#include <iostream.h> #include <conio.h> void main() { clrscr(); float secs,mins,hours,days; cout<<"Enter no. of seconds: "; cin>>secs; mins=secs/60; hours=secs/3600; days=secs/86400; if (secs>=60 && secs<3600) cout<<"No. of Minutes= "<<mins; else if (secs>=3600 && secs<86400) cout<<"No. of Hours= "<<hours; else if (secs>=86400) cout<<"No. of Days= "<<days; else cout<<"No.of seconds= "<<secs; getch(); }
Last edited by admin; 03-28-2011 at 03:29 PM.
-
Sponsored Ads

Reply With Quote





