Answer to Question #132129 in C++ for Javon Douglass Bryson

Question #132129
Add appropriate variables having descriptive names and comments for computing days and hours.
Add the statements to compute days and hours besides minutes and seconds using the initial total number of seconds.
One day has 86,400 seconds (don't use commas in C++ for numeric values).
One hour has 3,600 seconds.
Provide comments for days and hours calculations similar to those for minutes and seconds.
Enhance the output to include days and hours.
1
Expert's answer
2020-09-08T06:04:37-0400
#include <bits/stdc++.h>
using namespace std;
 //Conversion of second into days
void DayAndHourCalculations(int n)
{
    int day = n / (86400);
 
    n = n % (86400);
    int hour = n / 3600;
 
    n %= 3600;
    int minutes = n / 60 ;
 
    n %= 60;
    int seconds = n;
      
    cout << day << " " << "days " << hour  
         << " " << "hours " << minutes << " "
         << "minutes " << seconds << " "
         << "seconds "  << endl;
}
   
// Driver code  
int main()
{
    // n is the number of seconds
    int n = 18000000;
    DayAndHourCalculations(n);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS