Important C Notes
Important C Notes
wiT
lon
conditton at
O whut i bNNt9bN
Bttea OPeraion aBo nown
’ Tne condition aldecisi on wnanintool that
OPeratoyr iso a
ternaY
textcondino ino Pronaming
wer ed to looP5.
whie, it or foY?
stutements line
costeing 5 TYPe casin in c lanoua Ses
TYPe Gaps
is wsed toconverta
on data
anothen.
+Per to
Arithmntic. EnmesZion ?
. what is an
en Pre3ion i a combinaion ot
An AitnVmatica,la
Di advontue
Tne hoeut n on9e data s e t 3 9
Toves O(n) Hwe even t the elementis ean te
end.
are s
to Sear ch or
e d n
4 0rden af Gomplenity
6. wh at i8 ThoboBe case
int mainc)l
Stnuct srtudent S1;N b
\):
Pritf Enter rol, hame, end marK8:
Print! student
Ale Peiutt Rali 7.d\n Name: 7. n manws: -2fn
Asta?
3
OutPut
lol
etruct veywond
inside the logy.
membens (vamialkle) variable
2. behne
StrnctuYe to declone
the
3. yse
-NSNENN to Inside
st delemt
outside the stouctune 2.
Shruct Student
Struct shudent S1;
int id;
char name [So]
out nsi
Array of Shouctures
stohctune to store
omnat of
we ca cneat an
wlhple ecodB
I a inear dita
Notion af Linyed List- A uMed l t
Pointer to tae
Sructuve whene ench aemont (node)
hent
- File Handlju93
handlin 9 in collow& uta to oe storcd Peniout
File hoandin9
on the dis.
TYPes of
mark ;
326
Main( )
priut (
-toa Print
nwmber |
namez
malas 25-75
Ann at Stoucture
Fextane
stoneB mwiple valne stone3 mui Ple valueB
Datn of dierent datu tYPe. o
type of the Same PeDota tYPe
Dehnition colecion, ot elementCollecton ot element&
ot the Sume datutyPe of daffenent data t4Pe.
3sHeteno ene o h 8 w
Data tomo en e o s 9 w
Ype
Ma or may not be
Memornt contiuos memort
conti 8uoW
Albcatonlocotioni 6sit in
PurPose GnouP Simi lodata Grou? related
(e-g., ist of mnus) lenent dot
age)
Student
Struct Pott
int numbons[1-j1.2,34.5}; 'Char hame [so]:
iyt rol;
oat marusj
int Scones[3) =$00, 95, 73
Arra
Anat can be of ant tyPe String Can be
contun oul
line int, loat. char ch aracterB-N
stone wuliple item8. Storeg, tent or Sequen ce
of Characters.
Arrat size once
declaned
cannot be Changed. Aryp a si2e Can be
wodihed wsin9 Pointer,
Anrat does not end. witth a Stoing i
hul chanacie. ended With a'o
chenactr.
8,. what i3 loootin 9 ?
bte
Boo tin, aso Known
Proce3 of Sturtiug a comPuter. Booti n can be
done eithen through hond wae (Pressing the Stunt
b utton) or byOivin9 sotwane comm
aud, Thene fope,
a boot device is o device thot locds the oPenatnt
SY&tem. MOneover, it Contain the instucions and
Ales Which Stunt the
Computen.
Strnetunetoe Vnion
-The neY word struot i3
Wed heeyword nion
to dehne a 8tnucture. to dehvme awnion. i8 Wsed
Shhuetwre OccuPies hither
memor 8Pace.5olib Lo Union ccupiei Lower memort
SPace. over structe
We caM acces
al memben
of Shonctune ot a tme.
We
aCCess onlt one
Cay
Al member mat
membey of uni on t o tine.
ini halized.
mat be ini haized.
Consume ware SP ace conservation of memort
than únioW vorohb
include <stdio- h inelude <3tdio-h>
shrwct Data union Data
int i ; o N A
int is
Jloat
int main
)(a i o b noA uniom Data 3N
d Hod
Struct Data d di= o; .Kotali9.nob
Printt("Aer setiu9 int: dn
= 314;
Print(" stwtne:n): 6taols Printf ( After sethng fot :
Printi Int : hd\n d-i):k 2fn' d.f)
Prin"Float:%4.2f \" -f); Priati" Int (may be Jabnte):
neturn 0 dn d.i);
retirn o,at2
3
8 What is 9otoState ment in c ? what
o it
L- NotoömP
’ The 9oto Stute ment in e is to
Program Wsin3 abel It iz
omother.Part of the
Jum?8tute ment.
aso
d(i--)t
what iz the time complewtt of Bubole 8ort
BubbAe Sort i8 a simPle 3onhng aleoithm
nereate dl SwaP adia cent elementa it the
Hnat in the Wo9 Order.
ae
Case
Time complenitt EnPlanaho
ReBt Cse o() When the anpat i alnendt Sorted
(with an OPimized verzion wsing a
Fla)
Average
o) Ghener cose whene element ane
Case rendomit oder ed.
WOYt
When the aYrat8 Soypted in
Case oln)o pat neven se orden.
* SPace comPenit:
Tn3ert ion Set Simple, Perhorms well Does not deal well
On a sSmal st and Witth 4he huoe st
wini mah sPuce is reAired
Merse Sot It cn be aPPled to Requirez entra SPaeN
kles of
est Sonting aldorith m Digahantae with the
Suicu Sort and dealS verwell wonst case elfiienct.
with Lon ge st
Do- while
while
0 Do - whie JooP i3eit
0 while loop i8 entrt Coutrol AooP
Control boP.
.O A while ooP i a ADo - while looP i a
Pne- tegted LooP.taest Pozt - test ed oo P.
teststhe
(in tt test the Conditi0n ) It
at the end A the loop
betone enecuin the oop
lbodt
Semi coloy
(Tnene atne i8 no Semicolon yTne
ot the end o the JooP. at the end of the dooP.
e.9-’
e3> while ln<io)
DO2
Printd', ):
3
wide (h=l00);
MOAroa Souetn e
LefoAnratiBcolecHoo t r u c t u n e i8 the collecton
homo 9eneows ta bvs tes o Hetero Jeneows data
2 Avra data ane a cce8 3. Shoucture element ane
aLcess Wsin ) ot
Wbin indenonllano En.-S.nawe:
Eni- a[5] Cilssb
DYyamic
3. Arrat alo cales Stuh7c 3. AAtit alocate&
memort
memor.
elements take
5. Aprt element acceB8 taueg 5. Stuetune
then snue ture. \Wore Hwe en arat.
Les ime
G. Sntun’ G syntun
Stuchune
fvaniayle'i, vavjaule 2
Aray
Struere.
T En: Stouct student
it a5]: A
int Rol no.
a(0) a) a) aK a(4)
Enplain with enample.
Besic concept
An
anay of Point er8 hold 3 wemorg addnesses.
ivt mainl )
av iwt o=10) b 20 , e=303eiot..ow
pointers
rt
nt *anr31 l amay of 3 int
ar [o] = %a;
out Put.
Value t arr[o] =10
value. at ar[ = 2 0
Value at arr[2-30
what i maCr0 in e g
SYmbo tuot i8
A macYo 8 a
aud rerlace d by the macro boy,
bY the PrePyoces8or
Macro
in C
mction
ine MacrOS Live Macros
and
what ane the advantuges
Wachine level Lanouae.
blot&hbg
Bran ehing
eveecution
con s e q u e n t
Rhow
ehanin9 Ahe to tue aiferet
Branehin neler to Pro ram
the
condiion,, 1t alow
loased on
ene cuhon
Path.
9oto stude went
Uncondiona Branchin %
necomun e n
wt
and wtoh
i4-ese,
Win i},
Bnanchina-
Condhona
Printt i):tto
.a',
3
whide looP
Ew:-(Printin9 numlbeY Brom i to 10)
Ko include <stdio.hs
mainl)} Cievsn/
sot int
int i= L;
Whde (ie- lo)
itt
yetur o
3
Do- while Loo Cutosa
ron to o)os
(Printin 9. nwwber
t include < stdio. h>
ivnt main 07 :CniNNenDo
int i 1;
itt)
whileic= 1o);
return o;
collecton dements the.
Anpay - An
in ConH9uows mem ory ocatHon
dat type.toned
Some
inden d =%\ni,
Printf ( Element at
outPut
= 10
3 Element. at oinden
40
4 = SO
2-D Aaryay
Out Put 9
it)
for (int i- o; i43: öt)}
foy (int J=o: je4:
Print} "d, nwmena titi1);
3
chanacter Ayay
Char
Chan name 9 ] =
ur 8apuy
Char
int main 0
Char name 20];
name:
Print} Enter You
8eanl.3' hame);
(name));
Print!"Len 3th : lu ", trlen
sen ch NiNohat
NNtues of Linear
ad imple went.
ver simple to nderstaud Sorted
NO need br tue datu to loe
for Sm all dataset.
workwell
8 adv a n t u e
ihtolesst
datnset
Tellccievt fon arge
. In nea
Taues on) ime. even if the element i
ed
Binar/
|lo, 207
Tanget: 407(1 :(
1. LoW = 0. high = G
2. mid (o+6/4=3N)-(u)4
. What i
RecurBioni8 a Programmingtechniaue whene a
Foymua:
what i3 a stuctwre 9
A
deived data tYPe tu
alows Snoupin9 vialblez o itereut tYez wader ene
IwPotumee