0 ratings0% found this document useful (0 votes) 27 views15 pagesModule 2 Cs Sem 1 Notes
Module 2 handwritten notes of introduction to c++
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
Tokens
MR smaliet jodividual units
| tokens, |
|
| C++ has olloving 49 Kens: |
ia @ OAGraom are Known ay
| ° Keywords |
| Ddeak hers
(Constants
7 |
[Sigg
° Operobons.
|
| Keyusord |
| Due Keysords implemenkd spectre Cr+ language features. They |
| one exeheity reserved idenhters and cannot be wed ay names |
for Jt erqgram vontable or other user-defined program emenb .
Tdeals hous |
TdenkPers reher bo wa name ef vontadles, Ponehon , arrays, Clovse
ete. created by Aa progrommer. They ore the Lindamenta)
requirement of ony logguage . Gach lagguage has if Own rules
for namiag there wdeakkers.
Constaat'- Reker fo Fixed valut prot ao not chagge dering
the execuhion of pragrom:
Dota. types
A Bola types species dhe bype seecike
hor a vontable can shore, sh clekrming the amovab
ye [yor ot dole
of memory allecoled — for da vontadle gad dh Operohion
that con be perbormed on th| Cakgores of dato yee
used he deline vontables had shore simple values |
whrch inclde, |
> Fakeger yee: iat
- Floabag point fyee . Moat double
~ chooacter Yee + cho,
( Boolean Hoe :
Bool, |
| Operadors in crt
Ctt has gy rich sok of Operabors All ¢ opera)on One valid a
| ete also. In addition, Crt inlreduces some new op eralom . we
have alseady seen vo such operabew, nomey, ieverbion Operalos
kee), and the tebrackon optrodor (>>) oer new operabers ane:
I! Scope resoluon Oprotoy
7O* Pornkr 0 member declorator.
Scope Resolubor C5eraloy |
Like C, C++ & cdso a block -shuclured loyguage Blocks ard |
Stopes can be used in wonswuck ag PrBrams. we know Hot |
aniable name can dk wed lo have cliferent meanings |
|
Ky same ¥
in diPPerent blacks, The scope of the voniable extends Prom
ts porn) of its declonahion Hil te end of Hy block
conbataing Vu declorahrion. vantable declared inde dlock & |
Sarde b de local to Yak dlock. |Conssde, he i 7 m
follosiag segments of » ;
r9gra
Block 2
Block!Expression and Mhetr types i |
deere nGtoresewre
Expression
An expressron 8 Oo 6
’ ombinokon of
deesator.
Vorrabl rs, constont
es arranged as eer J rules op she faqgu bs and
Exeression enay be of the following seven byoet
+ Coastont expressions
+ Integral expresvons
© Float expressions
= Powndes expretslons
* Relakonal expressions |
° Lagreol exgprestrons
+ Bihoise expressiony
lenstoak (Exeres ‘ons
Constont expressions consist of onby coasank volutes
Ey’. 1s
rors (20
ye?
Tnleyol Exprenron?
Integral Expres os
al ty awomahc
are dhose which produce inkger vesulls abht
ond explrcile bype conyesrom.
implemending
By: ink x=10, 2?”
ink 2=24ty>
ba operaloy
coped yp phesr nome by operading on siggl operord
vnony operodoy ge
Eg:
ink XYBinary operador’ _
Binogy op eroloy get dheir name ly dking on Ino operoods
} {°
Float ab, ¢ 5
caat bo
bome Of de C++ operabors ads as both vaogy and Brno
oper odor zy
%:
a) Tu askruk 8 vied ow bineny qperabor +0 cai lbrnab<
mulkelicahon
fig: C=0*bs
wth potaler yootabe
| Eg: ial *@ly >
| + Fr =20;
Flock Exereuions
Flo) Expressions ane those ushrch , abler al conversions, prcduce
Plooiqg - point- feulb
eg:
x+y
x+Y¥/10
S + PlOos (107
107s
Poinkes Expressions
Pornkr Exgre2sioos produce, addres voluas.
1 dm
Ptr
ete +l
phere m 8 O vantadle and er is & POinky
») Ih ws wed as an ynary operator when auoctabe HeleRelabvong | Expressvons
|
Relabonal Exgreuions yild reuts OF tyre bool whth axe | a
a velur fr or tae \
£g:
O° xeny
O+b == tr
m+n > 100
then arcthmahc exprettvons axe used
velekonal operalor .
ON either side oha \
resulds
they will be tvalualed Mrs and thea she
Companed. Relokional expreurons One obo Known as
Boolean expreuvon
lagreol expsesron
lagicol expressvons Lombine
Produces d001 Iype resulks
Eg:
to o¢ more relabvona) expresvon and
a>b ¢€ 2==10
e210 Wee
| | Brkwhe Expressron
Bitwise Expresvon combine
tuo or more relolronal expres soos
and produce bool yee euky—
: ce Fa=10
| O>b-€
Bruise Expsesron
Bit Expresrow Be ysed ho manipwole dala ot bit love
arse,
“hey one bu ically wed for yesheg or shikbag brb
Fg: wee 3 Wshitt three bit postbon Wo lh
oh sgh.
yess Lshith one beh easkon 0 'Yyer a
Pee opera ———
(nee
bi abo:
rend opesabors
Ore Wied 0 porfoven dhe basic |
-pemeh< Operahoms such 0s addi \
" nhon, dubs .
| Gasron and modular Jeachen, mul bghcahioe
\
| ope whon | —~
[ater | CPemion | psa \ |
le ence \
— mi odiilton socakviky — wage | |
2 Lt |
| | oR ori +or2 |
.* | @eelSubsbackon 2 | |
L wR OF) -0P2 \
fu | Mabielicakon '
Lowe OF; 4062
/ divaren '
| L to R ©F/op2
Le ye enoindey
1 Lb wR ORI LOR?
Points fo remembey —_____|
2IP both Jha Operands one of byoe ink then dhe reudh is
alo oR type int this ts called on rokgee qnidhemobic
yy: ink x=10, y=20, 0,65 arty: beaty eat
\
“Lt bol Ie opted» ove of yee Plow , then He raw
also of kype Hood. Ths & tolled Moalng oink anvthendhc
+ Jn comping The remainder, 1P both Overonds one emikve
then Jt rernaindern posikve . TF ony ot dh a |
egg ve thon rerenndey is negakive | However , nole that \
i -, nathem dependent.
Sign of du romosnden is
'
ton: i inhonie, of a motherndicod
e Aritheoh'c excep lion gh ig the teuhonee ee
tompubokon of machint limitovon dut bo phreh Weg
unwonled —resulks
fa* int 0510, BS ~ oo
C= Yas);
ee ect| gy em
ginlde 10H reams,
yord MoLAr)
urance »
4 7
ishork ink 32764 4 :
yertes M93 2764 ;
wukeey> °
4
Fgvodily, Reladson and 1agreat
These oaperodors
Trae OM DIMOY ooeradoy,
ot tyee bool. Thot cube,
tik 18) and that oF fale
a barcavy Vaed to
~2¢0¢cbors
COmPare the Operronds. \
TH Yeu of Mise, opera 6
Frut O¢ baloe . The ink valuas of
mm ©
gperaler| Operaon | peggy
"| Precedence
Z tes than , L__fsoiodiviny usage
LweR
“a Les dan or eguoll pele tr2
’ L wR on c=0P2 |
| \\
> Greoker than | ' L wR 001>002
>= | Growler han or | ove \\
| s
egual bo | LR orir=0r2
ws bguedity 2 LR op)==0F2
=0P2
t= ineg ual ‘hy | 2 nbR oe
| - :
(gid operajors Me ved WO make decisions - Thy ane obo
Wed Jo connect fo or more roluion eagrenion.
Sferalor | oreradsoa precedence Associobrily "4 je
' tagrcod WOT ' al ‘ € OFZ
| . 7 | L Tok oat
| | logicod AYO | L108 opi t| OP 2
; 3 |
| | lagicat ORVv ———_
(me rouh oF lagyicol AWD opesabvon is Fru only it bosh
| ke operands one tus |
it Tend of legico) OR Operobvon is hue iP eidhor of chs
operands is bw.
+The wks Of lOgrcol NOT 18
5 folue ib dhe Qperond i hus.
kus if PM operond is Jolse aad \
Assignment 0 gerade. |
Tn (t+, the = Sign ss vied as an assygoment operas, Er
glaced bolveen ake lett hand side tderlrher and
Yight hand svde exprenron
idensher = expreuron
Fg:
Oink a;
Me12 Ze 4)
+ Inthalizakon and assygnment one diPherent, thaygh sey are
sing Mh same 83 Ygniment ogerosor l=)
-iniholrzabon of 0 yontuble con be done only One.
— Assignment lon be made ang umber oF Himes wihhin
Pragrom. Tk alsoys Over coride the Original ronknks.
s Tyee conversion: TP He tyoe of the voluy fo be ausygned
to dhs Objece =U MOF Jome as sa Ohyect Shon ik impicily
Coneurks sha valut fo He type ok obyert.
fg: ink result:
Youll = /2,50
Yor, vert oF tyre iak bub dhe VOW fo be auigned o
flogh 3°, Ro wv Coneckd to JZ
(TP dhe fype conversioa ws er imol icity, thea tompilor
|Qenerole an error
CO les earee
rompovnd anignerent % done be phone
asynment operator ty PIR Xing rhe OperolOr do ke
Overatoi Wear 7 a
[emsetT poraaioxgrmed [egcun aged
+ Os ath: adcuue
a. | @=a-bs | O- 242
* Ces OND: | oteb |
M5 Ob; oy eb:
Oreb
oth: |
Qi ab:
ata be
acerb:
GQ>rzabe }
increment and decreemen} operator
In t+, iatreament ogeralor reprtsenled as +t and
decrement Cperator is repsesened a —~-
facrement operoJor ology acts ona siggle ogeralos.
ott Can de placed bebre or ole ts operands, ih ib APPAR
bekve Ke operand it 1s called proincremen.
ih tt ov ~ is placed Oh» re operand it 1s tolled goo? increment
[+Eiher +4 2% Orxtte is wrihhea tadegend ently,
| condi bon ad oporakor
| The: yynro! 2 te ved aso condi honed operovor - Trt
|
| waditional opecaky Ternany Operoder ay t+ take Mhree operands
Sydtor +
| expressions ¢ ;[rm size of ( Operator
The Jizeok () Opesclor raurey dhe Jize OF an object or dose fyee
S228 (7 Qperador ShoWd be coritlen in lower cave leber
Tt shod precede rh operands. Ta operand onay e 4 consand
YONOBIE oF a dadayer
Eg! ink x
Size of (x):
Bituine operoy
A daba shen one shored
10 lOrmpukees memog as a seyuence
Os and 4s
e
| | Ass0 ciokvity | ty
Mok | R bot a
| JePt sibs 2 i 1 tor 5
| Right shite La twee ’
| bibue AND | 3 | Lee | i
| + bite OR | 4 | Lee | 1
A | bitae KOR | 4 twee
Thee operabors hele He gaogsammer ia duding ast setting
individual bh, Each bik-ndicdey q@ voluy a 0 orl, TREE
cso help in buildiqg dkuwe, shech ane a collecon or
indurd ual bib. Ustag dhe dikwelow One tan easily varity
ON € OFF ondihon of bids,
[2 The biteise AYO cperalor acs On dO inkger It perbrm
owe being on indvidual ancl corresponding biky tm rds
0 ORiondk, Thy Wh PF a dSitiise Anding wat when
bh bib ene 1 oherwue th ad.a ‘hun
>The bitune OR Orcidtoy ads on bvo a
youth of gq Bihane OR, eee
mg Uo ad Gp ont ot ty bis GA
and In Oo, ©. herve, if Loe
Oe Biheroe exclusive oR ogerakor adso ach: veon tt bo
Pook
iNHQ FOL Operands Te reuwk ob a dilvive KORing | i
‘ ‘ rv) in
re Ae diky ane dtP ferent. Obherwue . iF aO.Tha &o4
©
bovh bik ame either ts of Os . it fowls ia @Pony
ich'o . :
7 Prololy porn -
Stelgecing |
Fonchy
‘on IY
Probolyerng is
| ore ache, gerng One Ob thy mayor improvenant added to
| Functes, eb,
| saa Prololyping species He number and tyee oF aguemen,
| OS soy
| a
Calle gag pt Feu lyou oho Ainchon , ensuring proper hnekor
gee checking during comptlabron,
* Proto by
e's mondobos
Com padib |; ef in CHE bub ophonal inc be main toca
meal hy ord classre ¢.
7 aa.
| byee Rochon name (onguenent Jo
>
& Plow vot
u volume Cin} 4, Float b, weluen-
| int add (int a,intb, ink c)s
Soutle add (tlouble x ,double ¥);
1 bondion calls
tow ce add 15/100;
cout 2 add (Is; 10, 0);
couk Le add (1254.5 )5