Professional Documents
Culture Documents
DATA MEMBERS:
MEMBER FUNCTION:
Ans) #include<iostream.h>
#include<conio.h>
class candidate
longintano;
char name[20];
char category;
float fees;
void AFEES()
if(category==’G’)
fees=5000;
else if(category==’f’)
fees=7500;
else if(category==’S’||category==’T’)
fees=2500;
public:
void INPUT()
{
cout<<”enter admission no. and category”;
cin>>ano>>category;
cout<<”enter name”;
cin>>name;
AFEES();
void OUTPUT()
cout<<name<<endl<<ano<<endl;
cout<<category<<endl<<fees;
};
void main()
candidate c;
c.INPUT();
c.OUTPUT();
getch();
PRIVATE MEMBERS:
PUBLIC MEMBERS:
#include<conio.h>
class RING
intrno;
floatr,a;
voidcalcarea()
a=3.14*r*r;
public:
voidgetarea()
cin>>rno;
cin>>r;
calcarea();
voidshowarea()
cout<<rno<<endl<<r<<endl<<a<<endl;
}
};
void main()
RING ri;
ri.getarea();
ri.showarea();l
getch();
PRIVATE MEMBERS:
wno (int)
wname (20 character array)
hrwrk,wgrate (float) ( hour work and wage rate)
totwage (float; hrwrk*wgrate)
calwg() ( a function to calculate the totwage with float return type)
PUBLIC MEMBERS:
Ans)#include<iostream.h>
#include<conio.h>
class worker
int wno;
char wname[20];
float hrwrk,wgrate,totwage,ans;
float calwg();
public:
void takedata();
void showdata();
};
float worker::calwg()
totwage=hrwrk*wgrate;
return(totwage);
void worker::takedata()
{
cout<<”enter name”;
cin>>wname;
cin>>wno>>hrwrk>>wgrate;
ans=calwg();
void worker::showdata()
cout<<wname<<endl<<wno<<endl<<hrwrk<<endl<<wgrate<<endl<<ans<<endl;
void main()
worker w;
w.takedata();
w.showdata();
getch();
}
QUES2.4)write a program to define a class TEST IN C++ with the following
specification
PRIVATE MEMBERS:
PUBLIC MEMBERS:
ans) #include<iostream.h>
#include<conio.h>
class TEST
inttcode;
chardesc[20];
intno,creq;
voidcalcntr();
public:
void schedule();
voiddispdata();
};
void TEST::calcntr()
{
creq=no/100 +1;
void TEST::schedule()
cin>>tcode;
cin>>no;
gets(desc);
calcntr();
void TEST::dispdata()
void main()
TEST t;
t.schedule();
t.dispdata();
getch();
}