Write a C++ program to display Entered Time using class

By | 28.12.2016

Write a C++ program to display Entered Time using class

//C++ program to display time using class
# include<iostream>
using namespace std;
class time
{
        int m,s,h;
        public:
                void get(int p,int q,int r)
                {
                        h=p;
                        m=q;
                        s=r;
                }
                void display()
                {
                        cout<<"Time is "<<h<<":"<<m<<":"<<s; 
                }
};
int main()
{
        int p,q,r;
        time t;
        
        cout<<"Enter hour:";
        cin>>p;
        cout<<"Enter minute:";
        cin>>q;
        cout<<"Enter seconds:";
        cin>>r;
        t.get(p,q,r);
        t.display();
}

 

OUTPUT ::

 

Enter hour:2
Enter minute:43
Enter seconds:55

Time is 2:43:55

 

1 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments