My program works...except the value for my output is not what it should be. I should be getting the value of 48250 when input the numbers 13 24 10. Instead, I'm gettting -85899... Would someone out there be so kind as to take a look at my code and let me know if they see what is causing this error? I've gone over it line by line and am still having no luck. Your help is much appreciated.
#include <iostream>
using namespace std;
int totalElapsedSeconds(int& , int&, int&);
void elapsedSinceMidnight(int);
int main(){
int hrs;
int mins;
int secs;
int elapsedseconds;
cout<<"Enter the time in hours, minutes, and seconds."<<endl;
cin>>hrs>>mins>>secs;
totalElapsedSeconds(hrs, mins, secs);
cout<<elapsedseconds<<" seconds have elapsed since midnight."<<endl;
return EXIT_SUCCESS;
}
int totalElapsedSeconds(int& hrs, int& mins, int& secs) {
int elapsedseconds=0;
elapsedseconds=elapsedseconds+(hrs*3600);
elapsedseconds=elapsedseconds+(mins*60);
elapsedseconds=elapsedseconds+secs;
return elapsedseconds;
}
void elapsedSinceMidnight(int elapsedseconds) {
int milhrs=0;
int milmins=0;
int milsecs=0;
milmins=elapsedseconds/60;
milsecs=elapsedseconds%60;
milhrs=milmins/60;
milmins=milmins%60;
cout<<"The time in military time is "<<milhrs<<" : "<<milmins<<" : "<<milsecs<<endl;
}
#include <iostream>
using namespace std;
int totalElapsedSeconds(int& , int&, int&);
void elapsedSinceMidnight(int);
int main(){
int hrs;
int mins;
int secs;
int elapsedseconds;
cout<<"Enter the time in hours, minutes, and seconds."<<endl;
cin>>hrs>>mins>>secs;
totalElapsedSeconds(hrs, mins, secs);
cout<<elapsedseconds<<" seconds have elapsed since midnight."<<endl;
return EXIT_SUCCESS;
}
int totalElapsedSeconds(int& hrs, int& mins, int& secs) {
int elapsedseconds=0;
elapsedseconds=elapsedseconds+(hrs*3600);
elapsedseconds=elapsedseconds+(mins*60);
elapsedseconds=elapsedseconds+secs;
return elapsedseconds;
}
void elapsedSinceMidnight(int elapsedseconds) {
int milhrs=0;
int milmins=0;
int milsecs=0;
milmins=elapsedseconds/60;
milsecs=elapsedseconds%60;
milhrs=milmins/60;
milmins=milmins%60;
cout<<"The time in military time is "<<milhrs<<" : "<<milmins<<" : "<<milsecs<<endl;
}
