Comp Prac File_1451799830267
-
Upload
rohit-kumar -
Category
Documents
-
view
222 -
download
0
Transcript of Comp Prac File_1451799830267
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 1/82
6 4 C ERTFICATE
This is to certify that Harshit Raj Singh of class XII- A has submitted the Computer Science Practical ile! He has ta"en proper care and sho#n utmost sincerity in completion of this practical $le!
I certi$ed that this practical $le is upto my
e%pectation and as per the guidelines issued by C&S'!
It is further certi$ed that this practical $le is anindi(idual #or" of the student!
)R!A*I+ &HA+,THIA)RS!RAC' .,S'
/PT Computer Science0/PRI*CIPA+0
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 2/82
6 4 A CKNOWLEDGEMENT
I #ish to e%press my deep gratitude and special than"s to the Principal1 )rs!race .ose for her encouragement and support! I sincerely appreciatethis magnanimity by ta"ing me into her fold for #hich I shall be indebted to her!
I e%tend my heartily than"s to )r!Anil &halothia1)r!)anish Sa%ena12 )r!*itin Sa%ena my computer science teachers #ho guided me to thesuccessful completion of this practical $le!
I #ould also than"s my parents1 my friends and my
siblings for pro(iding their helping hand and
encouraging me throughout the ma"ing of this practical $le!
Harshit Raj Singh
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 3/82
6 4
I NDEX
30 S4APPI* 4ITH,5T THIR6 7ARIA&+'
Page-4 80 SI)P+' I*T'R'ST
Page-5 90 *'ATI7' ,R P,SITI7' *5)&'R
Page-6 :0 A' R,5P
Page-7 ;0 I*C,)' TAX CA+C5+ATI,*
Page-8<0 ARITH)'TIC ,P'RA=,RS /> - ? @ 0
Page-9 B0 I&,*ACCI S'RI'S
Page-110 S5)1PR,65CT A*6 R'7R'S' , A *5)&'R
Page-12D0 AR)STR,* *5)&'RS
Page-13
3E0 HC A*6 +C)Page-14330 PRI)' *5)&'R
Page-15380 PATT'R* T=P'-3
Page-16390 PATT'R* T=P'-8
Page-173:0 PATT'R* T=P'-9
Page-183;0 PATT'R* T=P'-:
Page-193<0 PATT'R* T=P'-;
Page-203B0 PATT'R* T=P'-<
Page-2130 &I*AR= S'ARCH
Page-22
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 4/82
6 4 3D0 S'+'CTI,* S,RT
Page-248E0 &5&&+' S,RT
Page-25830 CA++ &= 7A+5'
Page-26880 CA++ &= R''R'*C'
Page-27890 STRI* R'7'RSA+
Page-288:0 PA++I*6R,)' STRI*
Page-298;0 C,5*T , 4,R6S1CAPITA+ +'T'RS 1'TC! I* A STRI*
Page-308<0 +'T 6IA,*A+ , 8-6 ARRA=
Page-318B0 RIHT 6IA,*A+ 8-6 ARRA=
Page-3280 TRA*SP,S' , 8-6 ARRA=
Page-338D0 5*CTI,* ,7'R+,A6I*
Page-349E0 ACT,RIA+ 5SI* R'C5RSI7' 5*CTI,*
Page-36930 SF+
Page-37980
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 5/82
6 4
3! + INEAR S EARCH
#includei!strea"h$
#includec!ni!h$#includestdi!h$class data
% int e"&n!' static int c!unt' char na"e(50)' *!at sal' &u+lic, !id entr./'
!id dis&/' int rete"&n!/'
'int data,,c!unt0'
!id data,,entr./
% c!utnnter n! na"e and salar. ! "& c!untendl' cin$$e"&n!' gets/na"e' cin$$sal'
!id data,,dis&/
% c!utnata is ,-n' c!ute"&n!endl' c!utna"eendl' c!utsalendl'
int data,,rete"&n!/
% return e"&n!'
!id "ain/
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 6/82
6 4 %
clrscr/' int dl*ag0' data d(5)' !r/int i0'i5'i
d(i)entr./' c!utnnter n! t! +e searchedn' cin$$dl' !r/i0'i5'i i/d(i)rete"&n!/dl
% *ag' d(i)dis&/'
i/*ag0
c!utn:;< =;>:n' getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 7/82
6 4
8! & INARY S EARCH
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 8/82
6 4 #includei!strea"h$
#includec!ni!h$#includestdi!h$class data%
int e"&n!' static int c!unt' char na"e(50)' *!at sal' &u+lic, !id entr./'
!id dis&/' int rete"&n!/'
'int data,,c!unt0'
!id data,,entr./
% c!utnnter n!/in ascending !rder na"e and salar. ! "&c!untendl' cin$$e"&n!' gets/na"e' cin$$sal'
!id data,,dis&/%
c!utnata is ,-n'
c!ute"&n!endl' c!utna"eendl' c!utsalendl'
int data,,rete"&n!/%
return e"&n!'
!id "ain/
% clrscr/' int dl*ag0+l"' data d(5)' !r/int i0'i5'i d(i)entr./'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 9/82
6 4 c!utnnter n! t! +e searchedn'
cin$$dl' +0' l5-1' ?hile/+l
% "/+l@2' i/d(")rete"&n!/dl %
*ag' d(")dis&/' +reaA'
else i/d(")rete"&n!/dl +"1' else i/d(")rete"&n!/$dl
l"-1' i/*ag0 c!utn:;< =;>:n' getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 10/82
6 4
9! S ELECTION S ORT
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 11/82
6 4 #includei!strea"h$
#includec!ni!h$#includestdi!h$class data
% int e"&n!' static int c!unt' char na"e(50)' *!at sal' &u+lic, !id entr./'
!id dis&/' int rete"&n!/'
'int data,,c!unt0'
!id data,,entr./%
c!utnnter n! na"e and salar. ! "& c!untendl' cin$$e"&n!' gets/na"e' cin$$sal'
!id data,,dis&/
% c!utnata is ,-n' c!ute"&n!endl' c!utna"eendl' c!utsalendl'
int data,,rete"&n!/
% return e"&n!'
!id "ain/
% clrscr/' int &"inij'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 12/82
6 4 data d(5)t'
!r/i0'i5'i d(i)entr./' !r/i0'i5-1'i
% "ind(i)rete"&n!/' &i' !r/ji1'j5'j
% i/d(j)rete"&n!/"in
% &j' "ind(j)rete"&n!/'
td(i)' d(i)d(&)' d(&)t'
!r/i0'i5'i d(i)dis&/' getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 13/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 14/82
6 4
:! & UBBLE S ORT
#includei!strea"h$
#includec!ni!h$#includestdi!h$class data
% int e"&n!' static int c!unt' char na"e(50)' *!at sal' &u+lic, !id entr./'
!id dis&/' int rete"&n!/'
'int data,,c!unt0'
!id data,,entr./
% c!utnnter n! na"e and salar. ! "& c!untendl' cin$$e"&n!' gets/na"e' cin$$sal'
!id data,,dis&/
% c!utnata is ,-n' c!ute"&n!endl' c!utna"eendl' c!utsalendl'
int data,,rete"&n!/
% return e"&n!'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 15/82
6 4 !id "ain/
% clrscr/' int ij' data d(5)t'
!r/i0'i5'i d(i)entr./' !r/i0'i5-1'i !r/j0'j5-1-i'j i/d(j)rete"&n!/d(j1)rete"&n!/
% td(j)' d(j)d(j1)' d(j1)t'
!r/i0'i5'i d(i)dis&/' getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 16/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 17/82
6 4 ;! I NSERTION S ORT
Gincludeiostream!hGincludeconio!h
Gincludestdio!hclass data
J int empnoK static int countK char nameL;EMK Noat salK publicO (oid entry/0K
(oid disp/0K int retempno/0K
Kint dataOOcountQEK
(oid dataOOentry/0
J coutn'nter no1 name and salary of 'mp >>countendlK cinempnoK gets/name0K cinsalK
(oid dataOOdisp/0
J coutn6ata is O-nK coutempnoendlK coutnameendlK coutsalendlK
int dataOOretempno/0
J return empnoK
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 18/82
6 4 (oid main/0
J clrscr/0K int i1jK data dL;M1numK
for/iQEKi;Ki>>0 dLiM!entry/0K for/iQ3Ki;Ki>>0
J numQdLiMK for/jQi-3KjQEKj--0
J if/dLjM!retempno/0 num!retempno/0 0 dLj>3MQdLjMK else
brea"K dLj>3MQnumK
for/iQEKi;Ki>>0 dLiM!disp/0K getch/0K
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 19/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 20/82
6 4 <! + INKED + IST
#includei!strea"h$
#includec!ni!h$#includestdi!h$struct stud%
int rn!' char na"e(50)' stud BlinA'
'class list% stud Bstart'
stud Blast' &u+lic, list/
% startlast:>CC' !id insert/' !id del/' !id dis&/' !id search/'
'!id "ain/
% clrscr/' list s' int ch' d! %
c!utnPress 1 t! insert a ne? n!de' c!utnPress 2 t! dis&la. all n!des' c!utnPress 3 t! delete a n!de' c!utnPress 4 t! search a n!de' c!utnPress 5 t! eDitn'
cin$$ch' s?itch/ch %
case 1,int ch1' d! %
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 21/82
6 4 clrscr/'
sinsert/' clrscr/' c!utn:!de insertedn' c!utnEanna enter "!re/.@nn'
ch1getch/' ?hile/ch1F.F GG ch1FF' +reaA'
case 2,clrscr/' sdis&/' +reaA'
case 3,clrscr/' sdel/' clrscr/' c!utn:!de deletedn' +reaA'
case 4,clrscr/' ssearch/' +reaA'
?hile/chI5' c!utn<HJ:K ;>n' getch/'
!id list,,insert/%
stud Bc&tne? stud'
c!utnnter n! and na"en' cin$$c&t-$rn!' gets/c&t-$na"e' c&t-$linA:>CC' i/start:>CC %
startlastc&t' else %
last-$linAc&t'
lastc&t'
!id list,,dis&/
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 22/82
6 4 %
i/start:>CC %
c!utnCLS< LS MP<n' return'
stud B&' !r/&start'&I:>CC'&&-$linA %
c!ut&-$rn!endl' c!ut&-$na"eendl'
!id list,,search/%
i/start:>CC %
c!utnCLS< LS MP<n' return'
int nu"*ag0' c!utnnter n! t! +e searchedn' cin$$nu"' clrscr/' stud B&' !r/&start'&I:>CC'&&-$linA
% i/&-$rn!nu" %
*ag' c!ut&-$rn!endl' c!ut&-$na"eendl'
i/*ag0 %
c!utn:;< =;>:n'
!id list,,del/
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 23/82
6 4 %
stud B&Bc&1Bc&2' int nu"' c!utnnter the n! t! +e deletedn' cin$$nu"'
!r/&start'&I:>CC'&&-$linA % i/&-$rn!nu" % c&1&' +reaA' c&2&'
i/c&1start %
i/startlast % startlast:>CC' else % startstart-$linA'
else i/c&1last %
lastc&2' last-$linA:>CC'
else %
c&2-$linAc&1-$linA' delete c&1'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 24/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 25/82
6 4 B! S TACK 5 SING A RRAY
#includei!strea"h$
#includec!ni!h$#includestdi!h$struct stud%
int rn!' char na"e(50)'
'
class stacA % int t!&' stud t(50)' &u+lic, stacA/
% t!&-1' !id &ush/' !id &!&/' !id dis&/'
'
!id "ain/%
clrscr/' stacA s' int ch' d! % c!utnPress 1 t! &ush in stacA' c!utnPress 2 t! &!& in stacA' c!utnPress 3 t! dis&la. the stacA' c!utnPress 4 t! eDitn'
cin$$ch' s?itch/ch %
case 1,int ch1' d! %
clrscr/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 26/82
6 4 s&ush/'
clrscr/' c!utnPushing d!ne' c!utnEanna &ush "!re/.@nn' ch1getch/'
?hile/ch1F.F GG ch1FF' +reaA' case 2,clrscr/' s&!&/' c!utnP!&&ing d!nen' +reaA'
case 3,clrscr/' sdis&/' +reaA'
?hile/chI4'
c!utn<HJ:K ;>n' getch/'
!id stacA,,&ush/%
i/t!&49 %
c!utnS<JNK ;OR=C;En' return'
stud c&t' c!utnnter n! and na"en' cin$$c&trn!' gets/c&tna"e' t!&' t(t!&)c&t'
!id stacA,,dis&/%
i/t!&-1
% c!utnS<JNK >:R=C;En' return'
int i' !r/it!&'i$0'i--
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 27/82
6 4 % c!utt(i)rn!endl' c!utt(i)na"eendl'
!id stacA,,&!&/%
i/t!&-1 %
c!utnS<JNK >:R=C;En' return'
c!utt(t!&)rn!endl' c!utt(t!&)na"eendl' t!&--'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 28/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 29/82
6 4 ! S TACK 5 SING + INKED + IST
#includei!strea"h$#includec!ni!h$#includestdi!h$struct stud% int rn!' char na"e(50)' stud BlinA''
class stacA
% stud Bt!&' &u+lic, stacA/
% t!&:>CC' !id &ush/' !id &!&/' !id dis&/'
'
!id "ain/%
clrscr/' stacA s' int ch' d! % c!utnPress 1 t! &ush in stacA' c!utnPress 2 t! &!& in stacA' c!utnPress 3 t! dis&la. the stacA' c!utnPress 4 t! eDitn'
cin$$ch' s?itch/ch %
case 1,int ch1' d! %
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 30/82
6 4 clrscr/'
s&ush/' clrscr/' c!utnPushing d!ne' c!utnEanna &ush "!re/.@nn'
ch1getch/' ?hile/ch1IFnF' +reaA'
case 2,clrscr/' s&!&/' c!utnP!&&ing d!nen' +reaA'
case 3,clrscr/' sdis&/' +reaA'
?hile/chI4' c!utn<HJ:K ;>n' getch/'
!id stacA,,&ush/%
stud Bc&tne? stud' c!utnnter n! and na"en' cin$$c&t-$rn!' gets/c&t-$na"e'
c&t-$linA:>CC' i/t!&:>CC % t!&c&t' else % c&t-$linAt!&' t!&c&t'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 31/82
6 4 !id stacA,,dis&/
% i/t!&:>CC % c!utnS<JNK >:R=C;En'
return' stud Bi' !r/it!&'iI:>CC'ii-$linA % c!uti-$rn!endl' c!uti-$na"eendl'
!id stacA,,&!&/
% i/t!&:>CC % c!utnS<JNK >:R=C;En' return' c!utt!&-$rn!endl' c!utt!&-$na"eendl' stud Bc&t' c&tt!&' t!&t!&-$linA'
delete c&t'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 32/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 33/82
6 4 D! F UEUE 5 SING + INKED + IST
class ueue
% stud Br!nt' stud Brear' &u+lic, ueue/
% r!ntrear:>CC' !id insert/' !id del/' !id dis&/'
'
!id "ain/%
clrscr/' ueue s' int ch' d! % c!utnPress 1 t! insert a ne? n!de' c!utnPress 2 t! dis&la. all n!des' c!utnPress 3 t! delete a n!de'
c!utnPress 4 t! eDitn' cin$$ch' s?itch/ch % case 1,int ch1'
d! %
clrscr/' sinsert/' clrscr/' c!utn:!de insertedn'
c!utnEanna enter "!re/.@nn' ch1getch/'
?hile/ch1F.F GG ch1FF' +reaA'
case 2,clrscr/' sdis&/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 34/82
6 4 +reaA'
case 3,clrscr/' sdel/' +reaA'
?hile/chI4' c!utn<HJ:K ;>n' getch/'
!id ueue,,insert/%
stud Bc&tne? stud' c!utnnter n! and na"en' cin$$c&t-$rn!' gets/c&t-$na"e'
c&t-$linA:>CC' i/rear:>CC % r!ntrearc&t' else % rear-$linAc&t' rearc&t'
!id ueue,,dis&/%
i/rear:>CC %
c!utnQ>> LS MP<n' return'
stud B&' !r/&r!nt'&I:>CC'&&-$linA %
c!ut&-$rn!endl' c!ut&-$na"eendl'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 35/82
6 4 !id ueue,,del/
% i/r!nt:>CC %
c!utnQ>> LS MP<n'
return' stud B&tr' &trr!nt' c!ut&tr-$rn!endl' c!ut&tr-$na"eendl' i/r!ntrear %
r!ntrear:>CC' else
% r!ntr!nt-$linA'
delete &tr' c!utn:!de eletedn'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 36/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 37/82
6 4
3E! F UEU
E 5 SING
A RRAY
#includei!strea"h$#includec!ni!h$
#includestdi!h$struct stud%
int rn!' char na"e(50)'
'
class ueue% int r!ntrear' stud a(50)'
&u+lic, ueue/ % r!ntrear-1' !id insert/' !id del/' !id dis&/'
'
!id "ain/%
clrscr/' ueue s' int ch' d! % c!utnPress 1 t! insert a ne? n!de'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 38/82
6 4 c!utnPress 2 t! dis&la. all n!des'
c!utnPress 3 t! delete a n!de' c!utnPress 4 t! eDitn' cin$$ch' s?itch/ch
% case 1,int ch1' d! % clrscr/' sinsert/' clrscr/' c!utnLnsertedn' c!utnEanna enter "!re/.@nn' ch1getch/' ?hile/ch1F.F GG ch1FF'
+reaA' case 2,clrscr/'
sdis&/' +reaA'
case 3,clrscr/' sdel/' +reaA'
?hile/chI4' c!utn<HJ:K ;>n' getch/'
!id ueue,,insert/%
i/rear49 %
c!utn;OR=C;En' return'
stud "' c!utnnter n! and na"en'
cin$$"rn!' gets/"na"e' i/rear-1 %
r!ntrear0'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 39/82
6 4 else
% rear'
a(rear)"'
!id ueue,,dis&/%
i/rear-1 %
c!utnQ>> LS MP<n' return'
int i' !r/ir!nt'irear'i %
c!uta(i)rn!endl' c!uta(i)na"eendl'
!id ueue,,del/%
i/r!nt-1
% c!utnQ>> LS MP<n' return'
c!uta(r!nt)rn!endl' c!uta(r!nt)na"eendl' i/r!ntrear %
r!ntrear-1' else
% r!nt'
c!utn:!de eletedn'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 40/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 41/82
6 4
33!C IRCULAR
F UEUE 5 SING A RRAY
#includei!strea"h$#includec!ni!h$#includestdi!h$struct stud% int rn!' char na"e(50)''
class cueue
% int r!ntrear' stud a(50)' &u+lic, cueue/
% r!nt-1' rear-1' !id insert/' !id del/' !id dis&/'
'!id "ain/%
clrscr/' cueue s' int ch'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 42/82
6 4 d!
% c!utnPress 1 t! insert a ne? n!de' c!utnPress 2 t! dis&la. all n!des' c!utnPress 3 t! delete a n!de'
c!utnPress 4 t! eDitn' cin$$ch' s?itch/ch % case 1,int ch1' d!
% clrscr/' sinsert/' c!utnLnsertedn' c!utnEanna enter "!re/.@nn'
ch1getch/' ?hile/ch1F.F GG ch1FF' +reaA'
case 2,clrscr/' sdis&/' +reaA'
case 3,clrscr/' sdel/' +reaA'
?hile/chI4'
c!utn<HJ:K ;>n' getch/'
!id cueue,,insert/%
i//r!nt0 rear49 GG /rear1r!nt %
c!utn;OR=C;En' return'
stud "'
c!utnnter n! and na"en' cin$$"rn!' gets/"na"e' i/rear-1 %
r!nt0'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 43/82
6 4 rear0'
else i/rear49 %
rear0'
else %
rear' c!utr!nt rear' a(rear)"'
!id cueue,,dis&/%
i/rear-1 %
c!utnQ>> LS MP<n' return'
int i' i/r!ntrear %
!r/ir!nt'irear'i %
c!uta(i)rn!endl'
c!uta(i)na"eendl'
else %
!r/ir!nt'i49'i %
c!uta(i)rn!endl' c!uta(i)na"eendl'
!r/i0'irear'i
% c!uta(i)rn!endl' c!uta(i)na"eendl'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 44/82
6 4
!id cueue,,del/%
i/r!nt-1 %
c!utnQ>> LS MP<n' return' c!uta(r!nt)rn!endl' c!uta(r!nt)na"eendl' i/r!ntrear %
r!ntrear-1' else i/r!nt49 %
r!nt0' else %
r!nt' c!utn:!de eletedn'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 45/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 46/82
6 4
38! I NHERITANCE
#includei!strea"h$#includec!ni!h$#includestdi!h$
class e"&l!.ee% char na"e(70)' l!ng en!'
&u+lic , !id getdata/' !id &utdata/'
&r!tected, *!at +s+!n' !id get+s+!n/'
'
class "anager,&u+lic e"&l!.ee% char title(75)'
&u+lic, !id getdata/' !id &utdata/'
'
class clerA,&u+lic e"&l!.ee% char de&t(90)'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 47/82
6 4 &u+lic, !id getdata/'
!id &utdata/''
!id e"&l!.ee,,getdata/
% c!utnnter :a"e,-tt' gets/na"e' c!utnter "&l!.ee :!,-t' cin$$en!'
!id e"&l!.ee,,&utdata/%
c!utn:a"e, na"e' c!utn"&l!.ee :!, en!'
c!utnasic Salar., +s' c!utn!nus, +!n'
!id e"&l!.ee,,get+s+!n/%
c!utnter +asic sal,-t' cin$$+s' c!utnter +!nus,-tt' cin$$+!n'
!id "anager,,getdata/%
e"&l!.ee,,getdata/' get+s+!n/' c!utnter title,-tt' gets/title'
!id "anager,,&utdata/%
e"&l!.ee,,&utdata/' c!utn<itle, title'
!id clerA,,getdata/%
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 48/82
6 4 e"&l!.ee,,getdata/'
get+s+!n/' c!utnter de&t,-tt' gets/de&t'
!id clerA,,&utdata/%
e"&l!.ee,,&utdata/' c!utne&t, de&t'
!id "ain/%
clrscr/' "anager "(2)'
clerA c(1)' !r/int i0'i2'i %
c!utnnter details ! "anager i1' "(i)getdata/'
!r/i0'i1'i %
c!utnnter details ! clerA i1' c(i)getdata/'
!r/i0'i2'i %
c!utnetails ! Manager i1' "(i)&utdata/' c!utendl'
!r/i0'i1'i %
c!utnetails ! NlerA i1' c(i)&utdata/' c!utendl'
getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 49/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 50/82
6 4
39!) ATRIX ) ULTIPLICATION
#includei!strea"h$#includec!ni!h$
#include&r!cessh$class "atriD%
int "1n1"2n2' int J(100)(100)' int (100)(100)' int N(100)(100)' &u+lic, !id entr./'
!id "ulti&l./' !id dis&/'
'
!id "atriD,,entr./%
c!utnnter r!?s ! "atriD Jn' cin$$"1' c!utnnter c!lu"ns ! "atriD Jn' cin$$n1' c!utnnter ele"entsn' !r/int i0'i"1'i !r/int j0'jn1'j cin$$J(i)(j)'
c!utnnter r!?s ! "atriD n' cin$$"2' c!utnnter c!lu"ns ! "atriD n' cin$$n2' c!utnnter ele"entsn' !r/i0'i"2'i
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 51/82
6 4 !r/j0'jn2'j cin$$(i)(j)'
!id "atriD,,"ulti&l./% int rij'
i/n1I"2 % c!utnJ D d!es n!t eDist'
getch/' eDit/0' !r/i0'i"1'i !r/j0'jn2'j % int s0' !r/r0'rn1'r %
ss J(i)(r)B(r)(j)' N(i)(j)s'
!id "atriD,,dis&/%
c!utnJ is ,n' !r/int i0'i"1'i % c!utendl' !r/int j0'jn2'j
c!utN(i)(j)t'
!id "ain/%
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 52/82
6 4 clrscr/' "atriD M' Mentr./' M"ulti&l./' Mdis&/'
getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 53/82
6 4
3:!T WO 6 C HARACTER A RRAY
S EARCH
#includei!strea"h$#includec!ni!h$#includestdi!h$
#includestringh$class chars% char na"es(100)(100)' int n' &u+lic, !id entr./'
char B search/int' int retn/'
'!id chars,,entr./%
c!utn:! ! na"es t! +e enteredn' cin$$n' c!utnnter na"es t! +e st!redn' !r/int i0'in'i gets/na"es(i)'
charB chars,,search/int i% char B&' &na"es(i)'
return &'
int chars,,retn/% return n'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 54/82
6 4
!id "ain/% clrscr/' chars d'
dentr./' int *ag0' char A(100)B&' c!utnnter the na"e t! +e searchedn' gets/A' !r/int i0'idretn/'i % &dsearch/i' i/strc"&i/&A0 % c!utn=;>:n'
*ag' i/*ag0 c!utn:;< =;>:' getch/'
3;! P ALLIN
DR OME
S T RING
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 55/82
6 4
#includei!strea"h$#includestdi!h$#includec!ni!h$#includestringh$
class re% int n' char na"es(100)(100)' &u+lic, !id in&ut/'
!id !ut&ut/int' !id reersal/'
'
!id re,,in&ut/%
c!utn:! ! na"es t! +e enteredn' cin$$n' c!utnnter na"es t! +e st!redn' !r/int i0'in'i gets/na"es(i)'
!id re,,reersal/% char t' !r/int i0'in'i
% char str(100)' strc&./strna"es(i)' int lA' !r/l0'na"es(i)(l)IF0F'l' Al-1' !r/int j0'jl@2'j % tna"es(i)(j)' na"es(i)(j)na"es(i)(A)' na"es(i)(A)t'
A--' i/strc"&/na"es(i)str0 !ut&ut/i'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 56/82
6 4
!id re,,!ut&ut/int i% c!utnna"es(i) is &allindr!"en'
!id "ain/% clrscr/' re r' rin&ut/' rreersal/' getch/'
3<! IBO
NA CCI
S ERIE
S
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 57/82
6 4 #includei!strea"h$
#includec!ni!h$class T+!nacci% &u+lic, !id T+1/'
!id T+2/' !id T+3/''!id "ain/% clrscr/' int ch' T+!nacci ' c!utnPress 1 !r =i+!nacci series 1 /3rd n! su" ! Trst 2' c!utnPress 2 !r =i+!nacci series 2 /4th n! su" ! Trst 3' c!utnPress 3 !r =i+!nacci series 3 /5th n! su" ! Trst 4n'
cin$$ch' s?itch/ch % case 1,T+1/'
+reaA' case 2,T+2/'
+reaA' case 3,T+3/'
+reaA' c!utn<HJ:K ;>n'
getch/'!id T+!nacci,,T+1/% l!ng a+c' c!utnnter the t?! nu"+ersn' cin$$a$$+' ca+' c!utn=irst 20 ele"ents aren' c!uta + ' !r/int i1'i20-2'i
% c!utc ' a+' +c' ca+'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 58/82
6 4
!id T+!nacci,,T+2/% l!ng a+cd' c!utnnter the three nu"+ersn'
cin$$a$$+$$c' da+c' c!utn=irst 20 ele"ents aren' c!uta + c ' !r/int i1'i20-3'i % c!utd ' a+' +c' cd' da+c'
!id T+!nacci,,T+3/% l!ng a+cde' c!utnnter the !ur nu"+ersn' cin$$a$$+$$c$$d' ea+cd' c!utn=irst 20 ele"ents aren' c!uta + c d ' !r/int i1'i20-4'i
% c!ute ' a+' +c' cd' de' ea+cd'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 59/82
6 4
3B3BP ATTERN T YPE
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 60/82
6 4 #includei!strea"h$
#includestdi!h$#includec!ni!h$class &attern%
&u+lic, !id &at/''!id &attern,,&at/% int js' !r/int i-1'i3'i % c!utendl' !r/s1's3-i's c!ut ' !r/j5'j$5-i'j--
c!utj' c!ut1' !r/j5-i'j5'j c!utj' !r/i4'i$1'i-- % c!utendl' !r/s4's$i's-- c!ut ' !r/ji'j$1'j--
c!utj' !r/j2'ji'j c!utj' !id "ain/% clrscr/' &attern &' &&at/' getch/'
3! S ERIES
#includei!strea"h$#includestdi!h$
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 61/82
6 4 #includec!ni!h$
#include"athh$class series% &u+lic, !id ser/'
'!id series,,ser/% int ns&r&?s' !r/n1'n10000'n % s0' !r/&n'&I0'&@10 % s'
&?&!?/10s' snBn' rsU&?' i/rn c!utn ' !id "ain/% clrscr/' series s'
c!utnJut!"!r&hic :u"+ers r!" 1 t! 10000n' sser/' getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 62/82
6 4 3D! ILE H ANDLING(.DAT FILE)
#includestrea"h$#includestdi!h$
#includec!ni!h$#includestringh$class <RJL:% int <n!' char =r!"(20)' char <!(20)' &u+lic, charB Vet=r!"/'
charB Vet<!/' !id Ln&ut/' !id Sh!?/'
'
charB <RJL:,,Vet=r!"/% return =r!"'
charB <RJL:,,Vet<!/% return <!'
!id <RJL:,,Ln&ut/% c!utnnter :!,-t' cin$$<n!' c!utnter =r!",-t' gets/=r!"' c!utnter <!,-t' gets/<!'
!id <RJL:,,Sh!?/% c!utnetails are,n' c!ut<rain :u",t<n!' c!utn=r!",=r!"t<!,<!'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 63/82
6 4
!id "ain/% delete/<RJL:dat'
clrscr/' strea" ' !&en/<RJL:dati!s,,inGi!s,,!utGi!s,,+inar.' <RJL: t(4)' char str(100)' !r/int i0'i2'i % c!utnnter etailsn' t(i)Ln&ut/' ?rite//char B t(i)siWe!/<RJL:'
c!utnnter =r!" t! +e u&datedn' gets/str' !r/i0'i2'i % read//char B t(i)siWe!/<RJL:' i/strc"&i/t(i)Vet=r!"/str0 % c!utnnter :e? etailsn' t(i)Ln&ut/' int ltellg/' seeA&/l-siWe!/<RJL:'
read//char B t(i)siWe!/<RJL:' c!utnJter Nhange c!ntents aren' !r/i0'i2'i % read//char B t(i)siWe!/<RJL:' t(i)Sh!?/' getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 64/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 65/82
6 4 8E! ILE H ANDLING(.TXT FILE)
#includestrea"h$#includestdi!h$#includec!ni!h$!id "ain/% clrscr/' strea" 1234' 1!&en/X;KRtDti!s,,in' 2!&en/X;KRtDti!s,,in' 3!&en/<MPtDti!s,,!ut'
char str1(50)ch' c!ute!re change the c!ntents ! Tlenn' ch1get/' ?hile/I1e!/ % c!utch' ch1get/' 1cl!se/'
2$$str1' ?hile/I2e!/ % 3str1' 3 ' 2$$str1' 2cl!se/' 3cl!se/' re"!e/X;KRtDt' rena"e/<MPtDtX;KRtDt' c!utnnNhange L"&le"entednn' 4!&en/X;KRtDti!s,,in' c!utnJter change the c!ntents ! Tlenn' ch4get/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 66/82
6 4 ?hile/I4e!/
% c!utch' ch4get/'
4cl!se/' getch/'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 67/82
6 4
83! C ALL & Y 7 ALUE
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 68/82
6 4
88! C ALL & Y R ''R'*C'
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 69/82
6 4
89! S TRING R EVERSAL
Gincludeconio!hGincludeiostream!hGincludestdio!h(oid main/0
J clrscr/0K char ALB;MK int i1j1p1lK
coutn'nter stringnK gets/A0K coutn&efore change string is AendlK coutnAfter change string is K for/lQEKALlMUQVEVKl>>0K pQl-3K for/iQl-3KiQEKi--0
if/ALiMQQV V0
J for/jQi>3KjQpKj>>0 coutALjMK pQi-3K
cout K
for/iQEKiQpKi>>0 coutALiMK getch/0K
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 70/82
6 4
8:! P ALLINDROME S TRINGGincludeiostream!hGincludestdio!hGincludeconio!hint i1jK(oid pall/char AL3EEM1int l0
J int fQEK for/iQE1jQl-3KALiMUQVEVKi>>1j--0 if/ALiMQQALjM0
f>>K if/fQQl0 coutnPallindromenK else coutn*ot PallindromenK
(oid main/0
J clrscr/0K char AL3EEMK int lK for/int rQ3KrQ8Kr>>0
J
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 71/82
6 4 coutn'nter a stringK gets/A0K for/lQEKALlMUQVEVKl>>0K pall/A1l0K
getch/0K
8;! C OUNT , F 4 ORDS 1C APITAL
+ ETERS 1' TC ! I N A S TRING
Gincludeiostream!hGincludeconio!hGincludestdio!hGde$ne A*6 22(oid main/0
J clrscr/0K char AL3EEMK int lQ31clQE1slQE1digQE1splQEK coutn'nter a stringnK gets/A0K for/int iQEKALiMU QVEVKi>>0
J if/ALiMQQV V0 l>>K
else if/ALiMQ<; A*6 ALiMQDE0 cl>>K
else if/ALiMQVaV A*6 ALiMQVWV0 sl>>K
else if/ALiMQVEV A*6 ALiMQVDV0
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 72/82
6 4 dig>>K else spl>>K
coutn*umber of #ords are lK coutn*umber of capital letters are clK coutn*umber of small letters are slK coutn*umber of digits are digK coutn*umber of special characters are splK getch/0K
8<! + EFT 6 IAGONAL
Gincludeconio!hGincludeiostream!h(oid main/0
J clrscr/0K
int AL3EEML3EEM1i1j1nK coutn'nter limit of the arraynK cinnK coutn'nter elements of 8-6 arraynK for/iQEKinKi>>0 for/jQEKjnKj>>0 cinALiMLjMK
for/iQEKinKi>>0
J coutendlK
for/jQEKjnKj>>0
coutALiM LjMtK
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 73/82
6 4 coutn'lements of +eft 6iagonal Are nnK for/iQEKinKi>>0
J for/int sQ3KsQiKs>>0
coutVtVK for/jQEKjnKj>>0
if/iQQj0 coutALiMLjMendlK
getch/0K
8B! R IGHT 6 IAGONAL
Gincludeconio!h
Gincludeiostream!h(oid main/0
J clrscr/0K int AL3EEM L3EEM1i1j1nK
coutn'nter limit of the arraynK cinnK
coutn'nter elements of 8-6 arraynK
for/iQEKinKi>
>0 for/jQEKjnKj>>0 cinALiM LjMK
for/iQEKinKi>>0
J
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 74/82
6 4 coutendlK
for/jQEKjnKj>>0 coutALiMLjMtK
coutn'lements of Right 6iagonal Are nnK for/iQEKinKi>>0
J for/int sQ3KsQn-3-iKs>>0
coutVtVK for/jQEKjnKj>>0
if/i>jQQn-30 coutALiMLjMendlK
getch/0K
8! T RANSPOSING , F 8-6 A RRAY
Gincludeconio!hfor/iQEKinKi>
>0
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 75/82
6 4 Gincludeiostream!h J
int i1j1n1t1AL3EEML3EEMKcoutendlK(oid main/0for/jQEKjnKj>>0
J coutALiMLjMVtVK
clrscr/0K coutn'nter limit of arraynK getch/0K
cinnK coutn'nter elements of 8-6 arraynKfor/iQEKinKi>>0
for/jQEKjnKj>>0 cinALiMLjMK coutn,riginal Array isnK for/iQEKinKi>>0
J coutendlK for/jQEKjnKj>>0 coutALiMLjMVtVK
for/iQEKin-3Ki>>0 for/jQi>3KjnKj>>0
J tQALiMLjMK ALiMLjMQALjMLiMK ALjMLiMQtK
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 76/82
6 4 8D! UNCTION , VERLOADING
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 77/82
6 4
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 78/82
6 4
9E! ACTORIAL 5 SING R ECURSIVE
UNCTION
Gincludeconio!hGincludeiostream!hlong fact/int n0
J if/n30 return n?fact/n-30K
(oid main/0
J clrscr/0K int numKfor/int iQEKiQ3Ki>>0
Jcoutn'nter a numbernK
cinnumK int fQfact/num0K coutnactorial of num is fendlK
getch/0K
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 79/82
6 4
93! S TRUCTURE
Gincludeconio!h ALjMQV VKGincludeiostream!h j>>K
struct *amefor/iQEK*)!lnmLiMUQVEVKi>>0
J Jchar fnmL3EEM K
ALjMQ*)!lnmLiMKchar mnmL3EEMK j>>K
char lnmL3EEMK
*)K ALjMQVEVK(oid main/0coutnull name is nAK
J getch/0K
char AL9EEMK int i1jQEK
coutn'nter $rst namenK cin*)!fnmK coutn'nter middle mannK cin*)!mnmK coutn'nter last namenK cin*)!lnmK for/iQEK*)!fnmLiMUQVEVKi>>0
J ALjMQ*)!fnmLiMK
j>>K ALjMQV VK j>>K for/iQEK*)!mnmLiMUQVEVKi>>0
J ALjMQ*)!mnmLiMK j>>K
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 80/82
6 4
98! * ESTED S TRUCTUREGincludeconio!h
Gincludeiostream!hGincludestdio!hstruct *ame
J char fnmL3EEM1mnmL3EEMK char lnmL3EEMK
Kstruct Addr
J int hnoK char areaL3EEMK
char cityL3EEMK char stateL3EEMK
Kstruct 'mp
J int empnoK *ame nmK Addr addK Noat basicK
#or"K(oid main/0
J coutn'nter employee numbernK cin#or"!empnoK coutn'nter $rst1 middle and last namenK cin#or"!nm!fnm#or"!nm!mnm#or"!nm!lnmK coutn'nter house no!1 area1 city and statenK cin#or"!add!hnoK gets/#or"!add!city0K gets/#or"!add!area0K gets/#or"!add!state0K coutn'nter basic paynK cin#or"!basicK coutn'mployee *o!O #or"!empnot*ame O K cout#or"!nm!fnm #or"!nm!mnm #or"!nm!lnmK coutnAddress O K cout#or"!add!hno1 #or"!add!city1 K cout#or"!add!area1 #or"!add!stateK coutn&asic Pay O #or"!basicK
7/23/2019 Comp Prac File_1451799830267
http://slidepdf.com/reader/full/comp-prac-file1451799830267 81/82
6 4 getch/0K
?* ESTED S TRUCTURE?