Exforsys
+ Reply to Thread
Results 1 to 3 of 3

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 ...

  1. #1
    pamasan is offline Junior Member Array
    Join Date
    Dec 2010
    Answers
    2

    Unhappy 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.

  2. #2
    Manyamanas is offline Member Array
    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


  3. #3
    swapwarick's Avatar
    swapwarick is offline Member Array
    Join Date
    Mar 2011
    Location
    Pune,India
    Answers
    37
    Code:
    #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



Latest Article

Network Security Risk Assessment and Measurement

Read More...