0 ratings0% found this document useful (0 votes) 41 views30 pagesPPS Unit 4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
<4 NT PTF r ae
PRR
-— =
RAYS.
ae or euy is a collection ef values of Sams ole
> The values In autay ane Stop In Continuous
™
EMasxty Secatiron .
> The values Staoruid in cvviay Can be ameriedt (urea)
ce imecltx vatueg. that stants from © fo(n-!)
Chew m is the nos of elements cforved tn Te
— Feu of _Prays
@ Fa tegen artery +
‘> he integer aviay only Stores Ta tegan values
> The indigen antag ts cleclared ar
pnt 55 7)
doseeape ae ge Size oF covray, CAnything):
avvtaey
@ Flows cworay +
> The float areteuy only Stones Sloat vatves.
The float areagy 1s clclaned as
wot ge
Cire woinhi
Pfoes ¢ ae cea ae ain value Pen
dotatype Mors of Size of mamery: Camgptint
res
©: Chan cxvtay +
> The floet out ey only Stores chaz values
The chan anney is clredlarced? ars
Chan oo [ ai
raPnput an Arr
AH ee ay +
teinclude
ohh frclude < coniek>
void main ( )
inta £37)
for (iz0 5 188) itr)
z
seanp ("Aa", £AC5)) :
fo)
Quen)
4
# Tnitiolizotion of cou
The osviag Initializecl by Hy values encloseot
cody braces Seperiattel by Comma -
within ¢
Int a Leys OR Far les | 3, oo
ated acid oc
ine Co Je ola
inna C392 ¢ %Geen Wirite o program in C40 insert A Mets
end of WU .
Clemens at trend of BUTE
— > FB include cstelio-h>
HE Include ]
Void main ( } :
int aClo] , i, new, 5
POOKY C" Erton tas no. of eliments in cout
Stan (Las Bn:
fe (ise; fem gist)
&
we
Slang ("la dq £57);
P'b "La" a 0a7))
Stang ("70") bes):
Cen
7 Cito in) itr)
Pring Cd’ 1059),
gency)
4ues Wate O progyam in ¢ te dilte on elemondt
from the micelle of an cvvuuf:
Le dk include
sth Wnclode < Conio-bs
verdad main ©)
int AL to] 4, pos 5
fer Ciz oy 1895 ft)
é
‘Sean cred td ail);
pantp CES RALIT,
5
Seam ( SLet", 4P081;
for ( oe eo na)
£
atil= alpéd)
pes post!
4
for (ize ise ott
pang “A” cD)
%
gaunt),
4ves: oud. @ program in © 40 Aolof
——> #£ inctvole
oH inctucle
verd main c )
=
int alsj, bCs3, cCtoy, + 5
fer Ciao fsa Te)
Seang ( ot Yad" La Ci) eb C47);
POOL Oh Dol",
fer Creo 3 fs 4
é
iC any
ACAI 4b CHI);
7 ee)
al 6 6657:
prird$ Con
2
gory,
5
Cea)>»
+ Seanching in Arviays =
= Seoauchine mans to finel aw given clermniny Vy Oy
ry
~The a do techniques
Mu
+o Seasieh an
MOY Search 2 tye centr vie elimay
i tt of
From tne Stonting of erviay HU the en
of erie one by ene.
Gues~ Waite a Puogram in ¢ #0 Seonch an eLimty,
vO On comnay uatng Urrar Search ate.
— FE inchoate Binoy Suvich can only be apptrel en the
arriags Which cre Sorvtect. (Either ancancing, ©)
> Binaty search ouduces the no of sttps to
Search an element
DAL first Step the eliment fo be sea chrot
Ls Compareet evith the middle vatur of thy
aragy
9 TL the volt matches tren Prints “Llemur found”
DDL the element to be searchecl fA greater than
mide vali of antag thin Ser ow epuats
to mid +2.
TS the ebments to be seanthrel 1S Smalley fren
tht middt vals ef antag then be Sef Aig
egrets to mid ~ 4,
> Repeat Sip B after every B°% anol YPr Stas,. am 10
Gee Write oo POO” each:
elemunt wiry Binwy
— tbinclude
dt rnclude
void main ()
2
tnt aCS],5)
da Cina, 1297 170)
‘ : 'cl> oO»
gewieh, tome oj Nghe Se PMCS 0
Scang (hol" Lalit),
pring Teo’ a C57);
3
Scan ( hd") £ search)
whith ( bow! = hyh 7
: high) /2)
mids Cloe *
if (Seancn= = 4 Loyd)
printf ("Elemant Found’)
at 2
Breck)
3
else if (seaith > 4% Cray ele & eT conc”
oD pm f Bur
t elae if ea one at
aemd +45 A .
a “ di Conditan aahe ©
ebe
gee mid 1)
%
4=0)
cminth ("Clemens not found")
qubch (
:
. va tthe Binary Search Hechargve .
Guts" Ex plan ‘Y
Lwith Suifeble examples —
— All tha points of Binary Search ore exptas'neol
here
Now examples >
Lat array be
[26 ls 9 Jol ia}
Se te fe
Let seanch be [Ee]
Lit lows 0 , high= 6
Step ti mids (0+ 6/2 = 3
iflee = 0037) Fale
if (6) 9039) False
if (6< ac3j)
high 5 Bte2
4
Sepa: fud= (67>) /2 =}
if C62 seca) Tove,
pring (" Elemund: Found!" )"
5aE Sorting —
n ths
FF Sassting is 9 procen of avtanging FR elim
CAN in qncen cling ovelen or OlUsCE ning Oya,
+
> There oy many teehuguys 70 S0vt an array
Jan
@D Bubble sort 9 Tnereaving wre
7 Gece ce exteuring edt
OF
Ws Bubble Sorts
219126 U1, 6, BL, FL — CMrrenping in
AsCarcbing. oc
mena, | Sort ).
Passa 21, 9, 26, Uy, 6 BI, 22
i
Shp? oe
1 2t, 26, a1, 6, a2
3 done
ree etewa 212 6
5,2 260Ui,
5.20.26, rr
no
Ue oa. 4), 81, 9r
y
Aah 2, &, ui, $1, a2
NAnwor
3,21, 26, 61, UI, a2, @)- Gres tase argued)
Ror 2i- 9.28 26, 6, UP, 92, oy
9,2 26, 6,41, a9, 9,
Jit Mw re 14, aay 8,
Neronye
D2 6) 20, Uy, ae yey
3:2 61 26, 41, 92, 8,
ad» 6, 2e, UW, FBI
Se 2h 6, De, 4,
: 32. Ol
Pars 3% Je UI, 6, BO, Ut, 2, BI
Wes 2G, Ut) ay BT
9, 6) 2, Vey UT, FAL BF a “
Se 6. 2, 2e, UL, a2, B,
J, 6, 21, 26, ne
ee naa eer Uy 32. 8,
Ji 6, 21, 26, U1, 92, 9,
Pam 4 9,6, 21, 26, Ut, Fry BI
Bo
ci 3; my ae, Ut, Hr, Ot
6, 4, 21 26, UW, 42, Bs
64 9, Ue 2% Aly, FU BF
br Gy Wy Wy Hl, FA BI
Gio Uc Coa ey
Gi 9, Di; 8) At, Fay
ar
Tha given aniay fs Sorte.
; vod elemint ring Bubble.
Quer Sort te gen ™ ng
wet oo biget
6, Ot, BF, 2B, FH 29, 1H
10, SA, 63
#8 Pow at ey 27, 23,41, % 9, fo, WO, SI, 63
6, O1, BF, 26,41, 219,10, tro, $4163.
x
6) 3a, %1, 2B, Ur, M9 fe, He, S765
Leea
S89, 0%, 1, 41,219, fo, M10, $3, ¢
,
2
8,135, 29, Wl, 81,2, 9, Fo, Ho, S36,
Un
C1 2a, og, 41, 2, Bl, 49, 10, Ho, 53,64
S89, 28 41, 29, Bl, to, HO, sy
us '
e 4
6, 33, 2 41, 2, 9, 10, Ste 30g
6, 34,28, U1, 2,9, 10 Sli tlo, sy i
wy
C1 34, 24,41, 2% 4, 10, BI, SA, No 6
6, 34, 28,41, 2,4, 10, 81, $3, Gm
Fami2s 615%) 28,41, 2.9, 10, 8)
6139, 28, 47, 21g
ee
154, 63, iy
710, 81, 57,63, Np
6126, 37 G1, 21, 9, toy BI SI, 63,1.
ed ‘ 7
C128, 29, WH, 21, 9, to, 8) S52 63, Ne.
Nv dees
4,28) 39, 2,41, 9, fo, 8) sa O35, 110
Ms ? a
6128) 37, 21,9, Uy 0, By, $9, 62, He
ae
6128, 39, 21, 9, ry, hte $9, 63,0
6, 2%) 29,21, 9
1 (ora, BY £9698
©
012%, BA, 21, 9, Fo, “a sa, 8A, gu
)
6) 28139) 21,9, 10, Ur, oa, 6a By LP |
1o
6, 2%, 39) 21, 9, tw, Gi, ga, 63, Bir!
gg:
pans Bo GRE) BAL a By [OME EM ENT
6.2%, Ba, 21, 9, FO, GIy S71 SF, SENOS
Le
6120132, a1, 9, 10, Hy $9, SEs BI attO
—
gy Bes an,.9) 21 10) Uh ea ee el ee
A
6128, 2, 9,32 1 4H, SP, 63 B1r 1LO
612%, 21, 9, BO, 39, 40, 57) eg, oi, luc
XA
G1 2%/21, 9,10, 39,47 1 9, 631 BI MO
G92 Bi 21h 29 fo); 89, 4), SH, C31 Brito
nd
61 2p WS, 10, BR Gy FFL EB, SIMO
is
6, er 21, 9,40, 32, Ue, O% 63, Bry tie
4
€, 2%, A 9,10, 39, Gt, Sa, 63, BI , IFO.
Pars:4:- Cos 2), 9, lo, 33, Yt, 59, 63, % fi tI0
Cady, Oeergy-top PH, 17, C9, Bi pire
—’
Gy 211 28 1,9) fo (296 4 F9, OF Bry ITO
2
6. 2h a 39, 41, £9, 63, BI, Mo
.
Cy) 21, 9, fo, ea U1, $9, 63, BI; lle
io l
©, 21, 3, (0, 2, 32 Mh Sh, 63, BI Ne
C1 2h 9) (0, 2%) 25,4), £9, 63, BIyITO
6, 2, 9, (0, 28, 32, 41, ¢9,
C, 21, 9,
Cor,
Ot Ba
PO, 281 BOF Ut, 69, o4, Buphe
3, 16) 2B, 29, a1, $a,
63, Bt, Noe
$24, 9, 10,28, 39, Y,
S9- CRRA MOea, 63. Bl tro
Pow SS B,21,9, 10) 28) ga, 44
ez A
ga, 63,8!) No
eo eee :
Cr2rH
63, Blt
C1 Bs Bie Pe me, oan oe h
A 63, 8)
oo , But
er rte ee gay ott t 2
Ce ee 5) ie Ot ve
: 1 hr oe ;
GO oy eee ure SIe 31h Ne
1, 26, BA,
bo pte. ty 244 3% ai Soi Oo. Ula
xo
: _....~— 63,31, No
Tm
Cid, to, et, 266397 9h So Cee ai the
at, SA, O%, Rie fre
oy
Ce Dy bon tty 2 Be 34
68, Wert, Dk BYy UI, cay 3) ON
The given Otay F5 Sorted.
Aug Wet & pmagrom Ine do prderm bubble
Pecharque .
oy He include
ste tnetude Tconsorn>
verd mens)
provicling one
Int allod, ', Seep lz Jil jig] ler Iolvald
for C ize 5 aay it) unsorted onnayy.
Seang OLA, #4 C177,
nth CLO =
pond CL) & CFI)
3
for( feo > 1S 4 jet)
é
phefor (Je SIGS 95 Gray Seating et
ifCatgI >a Grad)
:
Sume = af guy: 9
{
ata? ocil oO Stvesp
ALCj] + Swap, ~
%
4 sootee
annay. Coortiog dare)
yeyey Veta
spor Cee 5 is ay itty es
2 Sel
Printh (" Lol", CIT)
5
GU ))
5
2} Selection Sort =
es 12, 2H BL 4 BE, PF G6
Step t° x 21%,
ny
Cons jel , Set
U, 36, 25, 44
4
12» BC, 2S. YE
cie2? GB te Se
Spe og tr el
Shp Bt 4131, %, It, BE, 25, 46
$\ Pewee
Consils are nos Smale
Step ae 4, %, 2h, ter 3H 251 6
ane. eo neeStip 6:
Stepo 4!
Sp 8!
shp J!
Step ll:
Shp I2*
5 U4, &, 21, 12%, BE, 25, 48
bat
Smet
|... st tt
oan —opgerk a
Cy Bil 2), Be; eae oe
C 21< 36)
Smats
Ne Swap
Sn Bi fo; Ol, 2c) 25, ue
‘Sooke
untovkad
41 B12, 21, 36, 28, 46
LU
Smelt
swap
4, &1 (2, 21,2571 36, 46
L ——-_ 2
Sorted!
Sra!
GC, ay 2 or as, 3 ue
(Ne Swep
GU, B12, 2, 2s, Bes 4G
a
Tht Qiven cuumey 1's Sovdeel,
Sb Sort Thi given anny wing Selactron Sort
techns'gee-
—> 3s, ¥!,26, tS, 91,46, 22%, Dvi9.
» Gla Sep 7! oe 26,15, 91, 46, 22,949,919
Beep 2! rth 26, 18,91, 46, 92,35,19
Step!
Oral
Sowt
WZ 4h
a
Smate
Swap
UN Sorteel,
Oc, |
oe
“Swap
oe 2,
22,
BS ald:sre W'S, 26, 41, 91, Ys, 22, 85, 19;
Sorted UNSerMte d,
sep 18, BEG, gh, MO as) 14
tN a
see 8" et, 19.44 91, we, 22, 25, 26
et ~
“Sorte | ere. ieee
Sep de Bel Sy tg, Gh 2 ule tan as, 2c
ay
Sry Toe
ier BP eG Cd eo
Sorted Unsorted,
Bet Ft te, at ae, Ur, ae
Smats a
Styp tor He! S, 19, 22, 26, “6,41, O54 a!
~ Sovked UN Lor ol,
Shep ths a gorieted), enheeorer, ay aus as¢ 3!
mn Kap
41 4G 7 3!
Step jap FNS) 19,22, 2, BoM, ot
ere: _———_ = ON Sextet,
Sovted
Shep 13 Ar 1S, 19, 22, 26, Me, Yhor 46, 91
7 Smal (Ne Suap)
No mre
—SHp 9, 15,19, 22,26, 95, Ut, Ub, 9), Smalten
Vaelver
NoTe- [te Mutticimensionel Arr ey
ale
com
(2 P Prvagys
2A multiclimensional aviay isa 2 lmtnsionas
WR Contains, value ateng MLY axis
» re 2
>A 2 Cmensione/ aviary is alo Called 4 Nady
>”
Mete; » Contains vatiues along Ys and Ey
o To =
Construct a mat. x in €
} prregrarmming » eye
2 loops v -
AE Declasretion Of 2-D avtoy 2
— datatype vor
: ay name le of rows] (Noo coim
CG int 9 £97 £37 Leptenration
“Chara COIL] (GE
+ Floas 9 C2708)
doubts 4637 C5]
1 9x3
Bus. Wrrk « program In & to Constroct a meuigux
~~ Ok Brows anol 2 Columns.
=> # inckie_X sted who
At inclucle < cenio. b>
Void main ( )
é turer
tnt gC 39027, 4 34
ter Cisco, i<25 fay
2
WeGiee | Yel ine)
é
[ Scamp "ha" f ecg}
pot C8 jopt occ F
D Getener; 2 -Perris
fare ted
yet WLC Aa program inc fx te adeliton
£ tnanreey -
2B. tH 'rclode |
D>-
tt netude < Conio-hy
void mon ( J}
é
ing4033039 , 6039039 ,c039 C35, 1595
for Cre oO fer ie)
2
7 ($05 $225 Gee)
Seang Cha Ld LACIE], bL CII);
pent ("ha hd" aciaeyy,Os
ail :
. Ze Wate program in ¢ 4° per fora te
Stbehacsion “ef 2 Meamicer:
at inelude :
H inelo oy < coni ov hd
Vore mon Y
é
int 033999, 6€39037 ,C£39039, 4, 5;
toCisoy isa 5 ite)
g
te (jres js y jer
g
Sed ( Adda", beociteiy, £603 ci);
CCiaci] = acer) ~ CiICIIY
Printt ("had ¢ Carer);
aoc),
3gue Wreten pregram rnc to eed fey transpose
a enn .
2D A include FH include Cdl ons
TH incline tt
é
po lfc, jars gee)
i C9 CIC I= 4Cj9C4])
e
Proth (" Mot Sgro etre" )
Keay
break 3
j
if (x==0) ,
print ("Matrix is summetaic” J!
L y gdh) 2
oo
xa
2.
ov
Two matyices-
BD #rinclude
at include < Coniorn>
ele, tee hoop
Veidl mein O) i
ge ante
i «od ae
Sp acryeay be fsCe, c C9043 kK)
Mer (jens aay ite)
: 7)
for (dr0 > Je sot)
2
Seanpl ad" Ea C17 C99)
printh ("Jl aCiICII),
3
fo Crroyys2 yr?
&
or (jee) GS35 dtr)
g
Seanp(" id", 4 BCIDLZI);
printh ("fel % bCICII),
4
L3 ae
dor (20) E's ia)
jet fig Zsa je
g ,
CEICIIE OS
\ ber Lee, K kt)
5 i
COC] + SCHACHT + ACIICI wb CKICIT,
Lo printe (SHA Ac CIICTI),
14
Ly
SHITE a pregram in © for mut py Cron Oo‘
TE STRUCTURE Ss
, cli ffounst
cP SAM UEHtO ina coll ection ae
data types
° T+ means Using shivenures We Can
Pitform wperation on mutta clatatypes
OF tht came din -
2 TRE Concepts of structine ils Just opposite
of an cut ay:
> Stee sa wre lt fined clate type.
A Dectanation of Styvetune +
& Iegwore US er clifinst
Pruct Sliuctwie nam dete ype
Int ay
Cha bs Membow of structoy
float c)
Int a}
3 We Shucte Vo abt,
= Hew +0 input ond ousput ths Strvcnut
H Include
floct b> - (ule bod (oubsiey Hy eroin)
Chay c}
ae ol,
7Void main ¢ }
2 wd
me ea
prot (hE Lege”
pa : rf AChAf 209) Wby ye
3
~ (tf the “the cleclaition /s out of Hue marn () then
wis global de Lonotion)
[Es the cuichasiction ts inside He main (7 then it
ty total cltcdarat/on:]
Ses Saale a Stuitable Shuctune tn Clangvage
Ketpring the Hecorels of thr employes
of. On onigeen! goton about they Cock » Atarmy
Designation 1 Salanys Otpartrent, city of posting
Also wrrtt & program In Cte Cntr the tows
of Loo employers and Ainplouys the nan
those Who eeumn More than 201 Cur:
=. te
tHe jaclude
include
Struct emp
2 Ls ustn aidined
clade ty pe
Int Cocks 5
char a C203 me Mutriply of chatncin Leal
? Sings
chat b L0d Lt faved secur dna i
tor cal woe (tre) fe wil be
; CLS)
chan © C300) eee
thor a Ciod,
Ctoop)
% m Lied Lag to ptoplsVold meu'n )
Int Gs
acy (" Yot YALL fol AAA" "wntiyeds, eh
Woe. 4 lied. Fer4, M4
PECTS 1615 tol Ls pA"
ter (reo; jg 93;
him cs3. sen» 20000)
re
Proth ( 7a ”CIIa):
TH nts nam,
“3
Feeeh 05
3
NL IJ: Cocke, LI
MEIVb, WLI) Seb) m5. c, » mCi] ))
itt)oe
gut Write a program in ¢ -to Store Hy clube oof
GE Sar stodentr intne database - The clutails of
Students ane Namy Stoll ne; , lipartment , branch,
matt in 8 Subjects Pom, Also Hsplay th
nant of Those sdudends Cho See mn thor
Bok mats in bork Phghlcn and MosttirmatHt?s
oy. HE incluele vstdio hy
HF include “Cele,
NCH P, nose 5 4
2 b JC, es
: a| pow Ciso; x 499 (+t)
2
4 Cb CaJ.P > FOV JEL (MOM D 70%))
: a
Printh (" YZ 5", x Ci] Aame) |
5
4
Fetch
sy
Ques Detine Structure with Syntax Also wsitea
P?° Fram thar Comparus two giver dots .
To Stove clade “rt Stuctwie Say dase FAat Contains
Thru members Namely datt, month, and yan.
If the dotes are vel then A
as Epes * ne Airplay menage
=> Ht inctude Strings we an viay of Characty datatype
> The formot specifier to Input and ortput the
Sting is "fa". .
> The String is always torminetcof by the Compiler
turing ult Chartacter” Oe