Menu

Custom Search

C++ lab Program

/*
i)justify the o/p of the following program
*/
#include
#include
class time
{
protected:
int hr,min,sec;
public:
char *ampm;
void settime(int h=0,int m=0,int s=0)
{
hr=h;
min=m;
sec=s;
}
void printstandard()
{
cout<<"TIME:"<<((hr==0)||(hr==12)?hr:hr%12)<<":"<<((min<10)?"0":"")< ampm=(hr<12)?"AM":"PM";
}
};
class time2:public time
{
public:
void printmilitary()
{
cout<<"TIME2:"<<((hr<10)?"0":"")< cout<<"It is "< }
};
int main()
{
clrscr();
time2 t;
t.settime(13,3,9);
t.printstandard();
t.printmilitary();
//cout<<"Inside main()\n ampm="< getch();
return 0;
}
/* o/p:-
Time1:1:13:PM
Time2:13:13
It is PM
Inside main()
ampm= PM */

No comments:

Post a Comment