HOME

Sunday, November 29, 2015

BASIC TO CLASS TYPE

#include<iostream>
using namespace std;
class sample
{
    int hr,mn;
public:
    sample()
    {

    }
    sample(int x)
    {
       hr=x/60;
       mn=x%60;
    }
    void display()
    {
cout<<"hour= "<<hr<<endl;
cout<<"minute= "<<mn<<endl;
    }
};
int main()
{
    int x;
    cout<<"Enter duration"<<endl;
    cin>>x;
    sample s1;
    s1=x;
    s1.display();
return 0;
}

No comments:

Post a Comment