Wednesday 27 April 2016

Class and Objects Program

#include<iostream.h>
#include<conio.h>
class day        //class
{
int hrs,min,sec;
public:
void accept()
{
cout<<"Enter min:";
cin>>min;
}
void display()
{
if(min>60)
{
hrs=min/60;
min=min%60;
cout<<hrs<<":"<<min;
}
else
{
sec=min*60;
cout<<sec;
}
}
};
void main()
{
clrscr();
day d;     //object
d.accept();
d.display();
getch();
}
/*Output:
Enter min:138
2:18 */

No comments:

Post a Comment