Menu

Wednesday, 26 November 2014

Chapter 5,Problem 5:Object Oriented Programming by Robert Lafore in C++ Solution Manual

//P5.5
//Ahmad Furqan
//1-3-2013
#include <iostream>
#include <conio.h>
using namespace std;
long hms_to_secs(int& hours,int& mins,int& secs);
void main(void)
{
int h,m,s;
cout<<"Enter time "<<endl
<<"(Format hh:mm:ss)"<<endl;
char dummychar;
cin>>h>>dummychar>>m>>dummychar>>s;
cout<<"The equivalent time in seconds is "<<hms_to_secs(h,m,s)<<" seconds"<<endl;
_getch();
}
//hms_to_secs
//returns the time in secs
long hms_to_secs(int& hours,int& mins,int& secs)
{
return secs+mins*60+hours*60*60;
}

No comments:

Post a Comment