Q:

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

0

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

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

//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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Classes and Objects Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C++ program to find Largest among 2 number... >>
<< Write a C++ Program to find Sum of odd numbers bet...