Assignment &
Explain exception Fand ting meshani@ in CH? inte a Prop,
in Ctt t handle line” by 270 erception-. 1
ehthen any enavorcah le Creumsfanee & (or me,
occur= in our pre, m then excephans Ore nour
nto! pedal functions “galleo! fandlers. This: grandes baa
erroY hanolting “mechanism whicn known Al excephon
hondling. 7 -
ocr exception handling mechanism makes USE .OF Hyg
Key words = Tey, theo fcutch, The thy represents Fre block;
slafements in eohich Fhere ave chances of Ocuming. Fome 7
exceprional - conditions. 2 G
“hen excepHon Cleikoteal « i trown uriny “the Fira aide
) Troe enirts a bbck of statements 10 whith thre excephor
finown in Fanclled appropriately. Thir block k& Called cakh
Hock.
*Divile by 20 exception :-
int main C)
£
double a,b;
wid dnide(clouble, louble);
cout <2 “ Enttr numerator’ ";
cin >> ai
Cout <<" Enter olenomenodor :" §
cin 77 65
clivide @, b);
t
we divide (double 7a, double #)
buy
fif (G==0) Frow ye
cout <<“ Reeulf 7%
Class Compore {
Tab;
~ public. :
_ Compare CT fast, T second )
soar { .
} a= fivst 5
b= secmnd }
1
Trmox C);
tomsfermplote. < cuss 7?
Tcompare ? 3) max 0)
! T vols : _
if (a>b)
vol = a;
elie
+ val =b5
yetum val
t
i be
intmain 0) {
Gmpowe ab} | (100,60) > *
Com pone < chow> obj 2C'p't')3~
Cat CO" \n poximum (60,60) =" < 5 TAT SRS eh yl
tem plake_< class 7, ROR SS
cles Compare | CTT Mn
Tab; :
pubhic
Compare(7 firet, T second J
L
Os frst}
j= second j
j
T mow (95
5
dempla'fe < closs T >
JT Compare CT? 2! max Cd
a T val;
a if Ca> b)
val =O}else
vol = b;
yelurm vols
5 o
int main C)
a Lint? obji(i00 760); sa
Compane. t
~~ T min (Ta, Th) ©
a
Tt Coch) -
vefum oy ore
else
yetum by
J
int main ()
f j ;
qut <<" min (10,20) =" ce = Ze enddj
cout [ihe Nemclard Template Uhrary XCstOye in collection “OF cdell’ Shatciur
enene c++ elesses (femplates) and jhuncfions//Bosoally sre
g@nsists firee basic Components: 7
LO@nidiner 2. Agoithms
* Oniteiner =
me @ntainer © O Collection of objects
There 0 bjecs afore the. oloda.
< Algovithny =
Tre algorithn.s OTe weal b process fhe contents off
The functionalities provided’ jn conlainer ave ra Ute
complex’ oporerions hence the algorithms are Uiecl to apport mae
@mplex operations fer the containers wpeeity The portions ip
comeinoy. The Weralas are used 7o tansvese The conten of conti
«Therater -- B
The jleratas are basically object: ut sometimes they can
be pointers ancl hence jteradters- : i
2st provider the concept of yeusable software components and
povider off--the- shell scutians 1 a wide variety OF pro promi
poblems- Bai :
«the Stl exemphties generic popamming rath Than object
Gienkd programming , ond. derives 11 prower and Hexrbility from
the use of templates, rather Than jnerifance and pelyy morphism.
Ht also owolde new and gleatlcetion—the olelefe for memory
management in fever OF eligcotos fr tovage allecation ord
deallocotion. He Gy “
Anesene tes___} youva
horate fmucrcl, bleinectiane]
a lable eramples?
| \The iterators are asec! to harene. the ontents
.| What is the. purpose Of Tlercitor? Ela
ma and random access Heroters with our
a of ra Th
= ave five typer of iterators. Ceetainey. There
= __|akandom acess 2) Fordard 3)Znput
; *) Ourput Bid bectional
fis « Forward Tterafor
he_elements can be storcol ay yefereved hyl- only frasord
moving kt alloweal.
+ Bidmechonal Iterator =
Store andl yefrieve the elemet anol fmiord /hackecard moving
tr qlloweol.
¢ Random acoces:-
Elementt can be stored or relieved randomly.
Ie
#indude
include < sist >
usdng namespace sel;
int _main ©
List Ast 3
tor (int i203 i <= 53 itt)
Ast. puch= back (D5. MGS Ay
cout << “ \n Tterating Hpraugh ist,..\0”;
Lid Zink> +: Const_iterotar rt»
2 fox (it = Jet-begnO ; it 1= tend O35 ++ it)
cout <<*it Ze" 4
cout << endL; vestVi:
xtturnd i
4
Output
Tterating Fhroagh Lit.
G2 seas ara| What is tack? How if 1# Tmplemented, Ut
STL?
A stick isa sogical concept That na af a_set of \amituy
elements-- The: ferm [s..OFkeD used in propemnir) andl me OY aay E
in Qmputn. / 3
Prograrn ining. slabhs ov Sasecl an the principle Fiettln Last Oia
g
# indule ‘
using namepowe tel}
tat main ©) -f
Stook sy ee
intern 5 :
Char ane; 1, o is
int chgisess yet \ Bi
do f _
@ut choéce ; OA SA
swytch (choice) { . A
caved = cutee \n Enter the element. fo > (aleheal a
Cin >> fem; O97 aS Ripa geaeay ay ye
‘Spish Cittm), a" ; :
cout ec" \n Tem ts purheckiii?:
beak; r 4
case 2: if As.empty0) DS BAYS
S pop C); :
COutZE* \n Poppeal an itmij| ”; a
; :a ee
else
@ut> ans;
3 oshile Cant = i
yetum 0; Paro
4 ve
.| What are He adaaiehss 20d Tiaclan 9 Sof aepuence
containers i
LA OW
Vector i eS:
Aduantoges:- ea
iy Theis dynamic in nature oi
iy Components may be intoduced, dele ed oY eof
ii) Seeral TMS Could! be kept. vn
iv) Tt is imipla to, tnitate: vectors ‘horror one ee Thea eat by Simply
2) ating ossiqninent \gporeter oo) >
Diraduantager-
i Vector C#t usec memory) creel ol
ip Tt iis\nat jnolexed. * ie
ti) Tf does not_make _ase_ofa Scones malin:ly) tase
> _|Adlvorrjages :
L There is no quavioge ot memory —
2 Inwetian and! aelehon operctions ore eae?
[Disaclventeges:
LAs list Is gequndal qntaner, ewe fave fo hove
hence searching is inefficient.
rile program fo, implement. MAP using: STL
= |#indudle