need a program written in C++ that will Write a program that asks a user to enter seconds, then display days, hours, minutes and seconds that equal to the seconds entered.
Hey billy, I do not know if I understood your problem or not. What I understood from you specifications is that you want a program that prompts the user for an integer and the program will conver the EQUIVALENCE of that number into DAYS, HOURS, MINUTES, AND SECONDS. So the program that I wrote is: #include <iostream> using namespace std; int main() { int iSeconds=0; int iDays=0, iHours=0, iMins=0; cout<<"Please Enter the number of seconds: "; cin >> iSeconds; if(iSeconds >= 86400){ iDays = iSeconds / 86400; iSeconds %=86400; } if(iSeconds >= 3600){ iHours = iSeconds/ 3600; iSeconds %= 3600; } if(iSeconds >= 60){ iMins = iSeconds/ 60; iSeconds %= 60; } cout << "\nDays: " << iDays << "\nHours: "<< iHours << "\nMinutes: " << iMins << "\nSeconds: " << iSeconds <<endl; cin.ignore('/n'); return 0; } Let me know if this is helful to you ^^
thats is exactly what i was looking for thanks a bunch
Join our real-time social learning platform and learn together with your friends!