You are on page 1of 4

1

Q.

#i
ncl
ud
e <
ios
tream>
us
ingn
ame spa
c estd;
cl
asss
tudent
{
p
ubli
c:charname [
1
5];
i
ntre
g no
;
i
ntage;
c
hardept[1
0];
i
ntsem;
i
ntm1,m2 ,m3;
f
loa
ta vg;
p
ubli
c:voi
dg et
da t
a()
{
cout<<"
Entername ,re
gno,age,
dept,s
em,m1,m2,m3
:"<
<en
dl
;
ci
n>>name >>r
egno> >a
ge>>dept
>>sem>>m1>
>m2>>m3;
}
f
loa
ta vg_sum()
{
avg=(m1+m2+m3 )/
(3 .
0);
cout<<"
Th eaver
a gema rk
s="
<<avg;
}
v
o i
ddisp
lay()
{
cout<<"
Th enameo ft h
es t
udent
="<<n
ame<<endl
;
cout<<"
Th ereg
noo fthestu
dent
="<<r
egno<<
endl
;
cout<<"
Th eageo fthes t
uden
t="
<<age<<e
ndl
;
cout<<"
Th edepto fthestud
ent=
"<<dept
<<end
l;
cout<<"
Th esemo ft h
es t
udent
="<<se
m< <
endl
;
cout<<"
Th em1o fthestudent
="<
<m1<<endl
;
cout<<"
Th em2o ft hestud
ent="
<<m2<<endl
;
cout<<"
Th em3o ft hestud
ent="
<<m3<<endl
;
}
};
i
ntmai
n()
{
s
tudents;
s
.getdat
a (
);
s
.avg_sum( )
;
s
.di
spl
a y
();
}

OUTP
UT:

En
tername,r
egn
o,age
,dept
,se
m,m1
,m2
,m3:
ak
hil
a
332
1
8
cs
e
3
43
45
47
Theaver
agemark
s=45Thena
meoft
hest
ude
nt=
akh
il
a
There
gnoofthest
udent
=332
Th
eag
eo fthes
tude
nt=1
8
Th
ede
pto ft
hestu
dent=
cse
Th
ese
mo fthest
uden
t=3
Th
em1ofthest
uden
t=43
Th
em2oft h
estu
dent
=45
Th
em3oft h
estu
dent
=47

Q2
.

#i
ncl
ud
e <
ios
tr
e am>
us
ingn
ame s
paces td;
cl
asse
mp l
oye
e
{
p
ubli
c:
charn ame[1
0];
i
ntre
gno;
c
hardesi
gna t
i
o n
[20];
c
hardept[
3 0]
;
i
ntBS;
i
ntHRA,DA;
p
ubli
c:
voidg e
tdata(
)
{
cout
< <"
Entername,r
egno,d
esi
gnat
io
n,dep
t,BS,
H R
A, DA=
"<<
end
l;
ci
n>>name> >
regno>
>desi
gna
ti
on>>de
pt>>
BS>>HRA>>DA;
}
f
loa
tgross_sala
ry()
{
fl
oatg r
oss_sal
ary
=BS+HRA+DA;
cout
< <"
Theg r
osssal
ar
yis:
"<<g
ros
s_sal
ar
y;
}
v
o i
ddi
spl
ay (
)
{
cout
< <"
thenameo ftheempl
oyee=
"<<n
ame<<en
dl;
cout
< <"
theregno=
"<<r
egno<<
endl
;
cout
< <"
thedesi
gnati
on="
<<de
si
gnat
ion
<<end
l;
cout
< <"
thedept="
<<dept
<<end
l;
cout
< <"
thebasi
cs a
la
ry="
<<BS<<e
ndl
;
cout
< <"
theH R
A= "
<<HRA<<e
ndl
;
cout
< <"
theDA= "
<<DA<<en
dl;
}
};
i
ntmai
n()
{
e
mp l
oyeee ;
e
.getda
ta();
e
.gros
s_s al
ary(
);
e
.dis
pl
ay();
}

OUTP
UT:

En
tername,r
egn
o,de
si
gn
ati
on
,de
pt,
BS,
HRA,
DA=
Akhi
l
a
332
Accou
ntan
t
Fi
nanc
eDepar
tmen
t
32000
1
2000
3800
Thegr
oss
sal
ar
yis:47800t
hena
meo
fth
eemp
lo
yee
=Ak
hi
la
th
eregn
o=332
th
edesi
gna
ti
on=Accoun
tan
t
th
edept
=Fi
nan
ce Depa
rtme
nt
th
ebasi
csal
ar
y=3 2
000
th
eHRA=12
000
th
eDA=3800

Q3
.

#i
ncl
ud
e <
ios
tr
eam>
us
ingn
ame s
pacestd;
cl
assb
ook
{
p
ubli
c:
charname[
100]
;
c
harauth
or[
50];
i
ntpubl
i
cat
ion
;
i
ntpr
ice
;
p
ubli
c:
voi
dg et
data(
)
{
cou
t<<"
Ente
rn a
me ,a
uthor
,pr
i
ce,p
ubl
ic
ati
on=
"<<
endl
;
ci
n>>
name>>aut
hor>>p
ri
ce>>p
ubl
i
cat
ion
;
}
v
o i
ddi
spl
ay(
)
{
cou
t<<"
Then a
meo fthebook
="<
<name<<
endl
;
cou
t<<"
Thea u
thoroftheboo
k="
<<aut
hor
<<en
dl
;
cou
t<<"
Thep r
i
ceo fth
eb o
ok="
<<pr
i
ce<<e
ndl
;
cou
t<<"
They e
arofp u
bl
ica
ti
onoftheboo
k="
<<pub
li
ca
ti
on
<<e
ndl
;
}
};
i
ntmai
n()
{
b
o o
kb ;
b
.getda
ta()
;
b
.dis
pl
ay()
;
}

OUTP
UT:

Ent
ername,author
,pr
i
ce,p
ubl
ic
ati
on=
Bel
ove
d
Toni
Morr
is
on
399
2007
Thenameo fthebook
=Bel
oved
Theautho
ro ftheboo
k=Ton
iMor
ri
son
Thepr
iceoft h
eb o
ok=399
Theyearofp u
bl
ica
ti
onoftheboo
k=2007

Q4.
#i
ncl
ud
e <
ios
tr
eam>
us
ingn
ame s
paces t
d;
cl
assh
ospi
tal
{
p
ubli
c:
charH os
pti
al
_n a
me [
20];
c
harDoctor_name[2
0];
c
harPati
ent_name[20]
;
i
ntcont
act_detai
l
s;
p
ubli
c:
voi
dg etdat
a()
{
cou
t<<"Ent
ernameo fthehospi
t
a l
,d
octo
r,pa
tie
nt,co
n t
act
deta
il
s=
"<<e
ndl
;
ci
n>>
H ospi
ta
l_name>>Docto
r_name>>Pa
ti
ent_name>>co
ntac
t_det
ail
s
;
}
v
o i
ddi
spl
ay()
{
cou
t<<"Thenameo fthehospi
t
al
= "
<<Ho
spi
tal
_name<<endl
;
cou
t<<"Thenameo fthedoct
or="<
<Doct
or_name<<end
l;
cou
t<<"Thenameo fthepati
en
t="<<
Pati
ent
_n a
me <
<endl
;
cou
t<<"Thecontac
td et
ai
lsofthepat
ie
nt="
<<cont
act_det
ai
ls
<<en
dl;
}
};
i
ntmai
n()
{
h
o s
pi
talh
;
h
.getda
ta(
);
h
.dis
pl
ay()
;
}

You might also like