Thursday, 22 March 2012

Print time in hours, minutes and seconds


#include<iostream>
using namespace std;
class time
{
private:
 int hour;
 int mint;
 int sec;
public:
 void get()
 {
cout<<"enter hours: "<<endl;
    cin>>hour;
cout<<"enter minutes: "<<endl;
    cin>>mint;
cout<<"enter seconds: "<<endl;
    cin>>sec;
 }
 void print()
 {
cout<<"you entered: "<<endl;
cout<<hour<<":"<<mint<<":"<<sec<<endl;
 }
};

void main()
{
 time t1;
 t1.get();
 t1.print();
}

No comments:

Post a Comment