Language C Notes
Language C Notes
Lamgua
IS a Commumícat e blw too
A Jamguage
ShaTe Some mfo maion.
eson s ohic Cam
pT0gsaNníng JLomgua
A. Natural domguuq8
puopose
Tqmit
Giample Te9u, Hindi, engish,
pTbagTam ming Jamguaqe
iS also
programminguanguage
oewee
beweem the
umícatomchammel device
Comm elechsomic debice.
the System
persoM Omd used to
danguagrs ae
poIrammîmg
the
Use
Use7 (am
Carm
applicatioms, The
develoP SoFtuware
PiogiammiMg
progiamm")
machime by using
mstuct
Wonguag
wTttin pud poSe
These taDnuH
enamples s
Pthom, CoBAL.-.
PASCALL, C, C ++Tava,
ASCTT
ASCTT Stamdsfo
AmeTi Cam Stamdaned Code fo mformaiom
Tmterehamgr
These c0u A56 ASCTT values
o ASCTL values
pointable -12-8
a. NOTmpintole 128
pintable 12-%
A 65
65 248 1
2 32-
160 -0
28-D 1-0
26-DD
3(-0
0 -1
011b0001
A bit 8 byte
OTOlOloTolol
a Compure g8
emeatomS of
tmp?ovmemt IS Called
process
the
9emeiasfom
(195o- 196o)
T GepeTadiom
9emesadiom ComPuters weTe
Jnfisst
TheseComPuters uwere
big 1 S13.
tuloes has maim CompoMEmtS
Vacuu
tubeS togethe made ome
18,000 vaccuM
Simale CompuN
Giemenatiom Low leve pooamaMma
Fst
UamguaR
St geme 1atio tBimoy Aamgua
Ramgua
T
1.e os 1's
eneTatiom (la Gó- 1a 10)
veplaced he tsamsisty
Compuess
RmStmead fubeg
fvaccum
Tn Second
emesaion AssAssembly Jamguag
itmeraiion 197D 14so)
amguan
English Jamqua Cormpil exs ias
mg Jamqua Techmics
PoO Tam
a+yoe
Algonithm
Plowc nant
Algonithm
The Stepby sTP pocessS to Complete a
ELample2
aa Alaoithm to demonSthatl
wi+e
Supey mas k BiIf Img SStem
Step 4 Stat
Step 2 s Tnpus poduct deteils
prOduct Mame ty P?íce)
B?1
Step3 Compute (om) caliculate the
BRll 6ty* poje
S+ep DiSplay the Bil Ci.e +otal amoumt)
pint he Bill
Sep 5
ShD
Step6
2 PLou chart
The qraphícal
o Symbolic epiesentaiom
a Stagt o emnd
a Ftowchantfo addiiom of
Draw
MumbUy Stayt
mPu
a b
Caliculatt
C=atb
display C
Stop)
Ouochantto the buildimg
demomst5ati the ouldimaa
Drad
Systm Supenman ket.
(Start
Tmpu
podduct detais
Bl price *aty
PontbR/
tin
orite a algonth amd diao a oD chau
nuiplicati o 3 mumb&u
o1 bm
Algoritmm PLoochan+
00
S.D PTR
Joo
Sep u3 Diplay S
Sep 5 Stp /Dispalty s
SdDP)
algonitho
a amd doaw a flowchar
suorite area
+o demomstsate the coliculasion ooteSs o
Flowchart St+at)
lP Pie value Rodus
Cfocumhence d Ciocle 1
2*3.IuAT*7
Aea
3-1uA *I
CStop)
nte a algon?th) amd dsa aflow chagt
demomsm ae the COmputati o ToCeso Area 3
perimeteex ofTectamal FLowehent:
Algi thm (Start
S+ep4 Stagt
(SD
algorithm md dhauo, a
Low chau
wite a
om process o
to demom Stval yCompudati
totas and aweTag ma1kS o Student 6
6 Subjects
Plgotm*
Sttp start
Stepa inpu THe,),Sc, Ma So
S3 Total TtH+£+Sc+So
S+epa Tote
St Avesaae TOt
Stp 5 Dispal Total
Step6 Dspla Average
Step t Stof
FLowchaTt (Stast)
P T,H,
So0
M,Sc,
E. 7
Total T+HtE
+Mt Sct So
AersageL = TOta
6
/bis pa Tota 7
Display Avena
(Sto
C- Larmauage
what is C-Jamguage
micldle Jamguaje
(eve
C-lamquage is a
CommplieT based, proce dura ConpuT pooqrranm
uamguag Sup pon img Stuctured pogamng
C is middle devel Jamguaq 9 meamS
botw Jow Jeve
Combines thefeatures 0f
amaua4 amd hiah deve Jamauag.
Cormpiler based meam S
eve Lamguag
Lamguag
tchamges the dada hig Jevel
Lo evel amguae
Tramsilo oliect Code
Sourtede
Enalish (HLL) Compile o's 3 4's (8imo)
c is a procedure Pogranimq dangaaL which
ha deived o Stuctuied poraroima
StsutuTed progamímg is used fo diuidimg
Complee poqiam intd SmaUe par ts which
ase he from fumcioms
Histors O C
C-iS developed byDenieS itchíe
Bell labs im OSA
1942 AT T
Ammericam Telephome Tdegnaph
AT T
ea amgua9 Develop
follouim9
. Opercdimq Sstem
UNI LINUX
. Pmbedded Systtm
E electomic deufce MiCroVave, washinq machme
Ocutalbase
SaL, MysaL, HTML
. Tet Edit8
wo9d pa d
E NOtpa d
5 NetwoTk 07i vey
C: Rootens, hubs, Suoitch
G G1ammimq Animaions
Commpîley 2 Tamsistty
8 Brow S
Bdit3y s
C- Used to
S|wtoolS used
C-EditL3 aithe
NO. of
Loníte -oqTamS. There aTe 0. 0f
edit33 au
edít69
fditou Some of popul
JRted below
TUTb0 C
TuoOC++
onyc
*NOtepad t+
edit plus
we Com oríte
Ecli pse
C, C+t) TUG
Dev c++
Code te Phythom, SaL
Cod e blocks
Net Beams
ATOM
visiual Studio
Brackes
Buefish
Subllm eted
VIM
-edit+
EdE
JED
PS-PAD
Ho to open=C
Sfomple C-pTogTam
usimgTurbo c
wite a
Steps to opem TusboC
iCOm
ABy usima esetop TuiboC Shonttut
3usimg Comamdphomt.
windouS t R
Run typeCmd
in
C- C
C:\ Cd.
Cs. Cd
C
Simple proqTa7
TO wTite a me Poaram pess
At+
maimC )
2
printf C" welcome to C-domquc
cisscso
pPintd (" Hello womld")
Output s.
Hello uwiyld.
1tcht to hold the output
is used
etch
uorthout usima Alt+FS button
?
*wte a pTOTam oy usin
3cht)
maün)
clnsCO3
Heuo wo7ld
Printf1
aekcht
3
outpuFe
Hloo091d
EScOpeSequemce
The escape Sequemce COmcept is used
ouwpu pe ue
to dsplajimg the a
Fequiememt
t
t s used Gemeadta tab Spales
4 tab = 5 Spates
s usedHo he previ0us
Tt
the slashs
\a los) 0011
OUMa
TE S used esne ati beep
Calas m)
-osmfeed Symbo]
Tt S ued 8emeT ate
PTOgTamo
WTite
escape Sequermce.
maim
cliSCTC)3
Primf C" hello m Niaamaleca "
3
mouoledg is powen
Pitf
pim (" Healt fs wecth \
atch
Outputs
hello
Ni3amabad
helld Ni3amabaa
heu
hllo This is CosTia un
This tsfo feed symbo
Kmouledga is Pouwe 3
headth fs weut 73
Rules Regulafioms wTite a P0gTam
charseF TOkemnS
case FeyoordS
a-3 (ouwes )
Smbols
Softwa
1okeMS
Keuoogdss
aly0 Called Tesenued
KeooydS au
FeHw07 ds
wOTds C-Suppase
used fo a SpecificC
kyu0O% d S L
These
puspose
hile Simqed
1 imt 4
10) fox sim3D
2 shot Switch la umsiamed
3 omg Lase
20 eiSHey
u floa 13 oeak
double
23) Void
5 l4 Comtinue
23) Volqile
1S goto Tetuy
else
Stsuct
do
a Chad
91) emu
Staic
24) Comstamt
3 ien
31) default
3 ye def
TdemtiHers CVaiable S)
mameg of vaiasles;
Tdemtifieis au the
functhomS UmiomS
SructuTeS
Nouable 3
Dasatype
defimtd Vasiables
Dattyps au used to
re DfF data which we
The determinsthe
are stoimg he vOuaoleg
Dodar
NumensC StsuctuTe
UmiomD
ehar
Emum anate.
Jon F stsim
lca dadayee
double
Dataype St3e omveSTo
Specrfaer
chad - bHte 28 t0 12
double &loyt -
l7 e - 308 +D
+11e -
308
3.4 E
l0x 3.4
+3.q E l05 x3.y
bt I0 D
ubitS= Imibble
byte bits
02u byt
024 B A G8
1024 G B TB
L 24 TB 1 fB
Comstamts s wom E
fized values they onE
ComstamS ase he
ene cuibm of he PoO8Tam
Chamge while
Declaratkom of vniable s
+S dadaty pe
Defmmg a Vauable mambe
yoids 1e
S 03
declanoHom Of
kmouom
SymtactL
Dadatype Voialblemome
enamples
floa a
emt s
Tmialu3aiomCD)asS
ASS1nma giving value o he
S O3 asgiqs9MeMt
Vauable
Symtan
Vaniable mame value
Lomples
an 0
100
a 9993
S
mtsm 1s used
mumm bn, T+ 6CCupfe
Stomes a whole
ohic
a byy memmd
o memou
loaug
floadt iS used to Spefy he vauably,
factiomal numbey, the Stae
ohic StoTeg
of floa s4byt
doubles
The enLtenSío) d loat is double.T
bCupí by memm
u
Smeds
we cam PTefi1 Stamed to amy mumeT íC
Mumb eg
Chagacter cchar) 3
Shim
chasac fers s Called ag Shrimg
Shring.
Grsoup of
Stsing 1S mot a datutyee. but to Stove a Sig
fumcHom sed to
printf s Sameared
Prinin om +ent3
Synta1 8
grmt("tent ")
ample 3
Syntaa9
" Vatab1ename)
printf C Teat Con-Spectfie7
s
Eample
ollmo
pimtC you dll no is
Vadable Vale 8
Pinimaomy
Symta
poimtt C" Com-Spe ciRe, va{ aloe name
eamples
ci ScTC3
int hmo 3
ht no LO1
numm be7
Prit(%d is yous hal fícket
tcht 3
nt a biC
O-100 3
.
b20 0
e Atb3
primtf (add o ab 1, d c
9ttet3
3
Duput s
Cdd o atb 300
moim
imt
clo seC3
C lo0+200
Printf (" add of ab is )
Tod"cc )3
getchc3
C10d
b-20d
printf C
add of ab is d " (atb))
atcht
3
Ouput add ao is 3 oD
maimt
ClHSCT3
Pri C" add t3o0))
of ab is d20
etcht
mt
elTsCTo3
m2 5
m310
tot= r1+omm+m3
avg +ot 3
%d 3
of he Studemt is
Pntf CThe t0tal magks
tot3
getth3
3
oud put g
0
the the Studemt 5.0000
Scamf s
Scamf) s Stamdared impudtunctiom, it
is used to accept dadta at unti me
ihe Use7
SHntaa
Scamt( Com- spe 1 Vasiablename)g
ELcmple
imt
Primtf ( Emtes i
value")
S canf %d", Si)
mame
wTte a pgTam to aept ou
amd displayit
ynain)
cha st i53
elrscoC)
closC
erintf ( ent mumbe 1m
output
Cmtey mumbe?
10
mum bes íS 0)
The
vaues
wwite a proqram to att ept a, b.c
maim )
imt a b C3 d3
ClosCo t
printf Emtti a values m")
Scanf ( 7» d", 4a)3
a
Scamf %d4b)
pint emt c value Im")
Scanf("" 4t)
d atb+C
prmtAediHom C b s , d
jttht
Du pufs
EMteya value
13
mted b Valule
13
Value
13
,
-
Valuy
write a program A accept P t7
Computfe display the Sim ple n trest
maimt
int P, t 7 ST
clrscC)
emte P value m" )
primtf
Scanf ' /, d ", 8 P
poim+f" emtet value m")
Scamf C 1,d", 3t)
Primtf(Emtd 7value m))
Scamf C" Vd"> 7)
SI P *t* oo
s %d ST)
prinif (" Simple nsest
getcht3
3
oudputs Emte P vaue
00D
Emtt tValuue
Emte ValJA
Stan ,
pTimtt("entti aty m ") 3
à ", &)3
print fntey pi ce m ") 3
amt P
printC" ** * Amupama Hypen Manke *** mJ
,
Printf *** Vaumi Poad 02B **
pin pyoduct \t aty 1t pricelt Amt m
Pm C7S \t).d 1t %d\) Pname, iP.amt)
int ** thankou 1sit Aga
etcho
Oudput3 *
*Amupamma Hype MaTket
EmHes product mame
Rice
emtes aty
Emted Pie
Amt= \000 A
OuP u be
Studentnorme3
fathe mome
Hol Hcicet m0
M
St
SO
1GY FS SecuTed MaX pa.s S
Subject Pas s To1a
maim
SCanf (7,d", M
printf C emte Se Maks 1
Scanf C%d°, & Sc)9
m")3
pointf C" Lmted So Maiks
Scam C" %d", So)
pimtf ("In Entes the totad days of Schoo: Im)3
Scamp(d", ztdaa s
psin " In enles the poesemnt days o Student m )3
Scam C%d" 4Plays)S
pmntf (" PRO 61ReSsS RePDpT CARD **")
print RollNO: */ d \t Smame et 7.s \E fmame
S D", RolNO, Studemt name, faHhenmameJ=
dPda8)
echc
Casim 9data Comversíom 8
ype Comversion TYpe
tu amo thEY
amo in
Comve7tmg data fron ome daatype
data ComveSiom
datatype s Kmowm
SuppontS to P of data
dar
Cdangucge
ComvenSiom. They aL
a Tmplici t
assígmmemt opeg ao7 s kmowm
data ConvenSiom.
Compley self
Self
done b the
Inpli Cct
npi
Lowes Dota type HRahes Dada+yPe
E Chan
Shost
aPPogram Comve1t doda faoro
wite
9mteged to Floas,
main
ent a
floa b
ClosCo C)3
a-l03
ba
primf (" b value fs
f \m" b3
tcht3
Oudpufs
bNalue s O.0000D
Maint
locd
nt b
a LD 58
ba
Pi b value is .d M
qechtJ3
oupus
bvalue is 1o
fom
hom a
p%oqramto Comvert data
wTTte a
chan to
mum lbe.
moim t)
cha i
clsscoC
A
J13 /d \m". jJ
primtf("Vae Ís
getcht
3
Outputs Value is 65
maimt)
chas i
mt
clTsCo C)9
prin(" Enten a Cha 1m")3
Scamf [ %c 1) 3
ASCTT Vadue is d mÍ
poimtf("
getcht
3
AsCIT Nalue 1s 65
ent3
cho 3
clssCTC)3
USe defined
Cam Hpe Cast t0 ake he
USed
ponticuaru dadatjpe.
CowenSiom
maim
a C
float C
1S 3.3333
div ofab
s
PTOgamín
Structwse OfC
DeclagaHon Sectiom
ImpwSeion 3
tcht
ERasmple proasam
onumbSy
ni+ewn+e apoa aMM
wit StsuetuNe.
usin
ogTam Of
Additiom Dfa mumbr*/
Demmo
#imclude< Stdio- h
Hmctude Como. h
Void maimc )
cisCs C3
printf emtes ab values Am"IS
Scamf C%d % d'>
ya &b)
C atb
pimf (" Emev a b values m ")
a b)
Scan"/d % d'
Catb2
pyitf (" Add of ab is od m C)
cht)
20
Add o
ab s 30
Conent Setioms
reiney whfch gives Infor-
7 Commentase Code.
natiom abou hePdoTam
Commm
em u he follooig
oe Cam Specify
Syrnbols
19m0% ed he Compiles.
Comm emts e
putot)
imcludeStdioi h"
iprint () Scamt)
-
Com&ole Tnput ouwfu
funciom #im ctude<Comi O.h)
elsco C)3 gcht
Himclude Comio n
Macth -fumcion
Pouol)3 4includezmath h
Sqgtt)
Jogt Sfm
Opeiasa
C Jamgunge SupportS o Vasuous typy
OperadY
1. AithmaiC OpeTatsy
a. Reladionad opeiady
3. dogical open ady
mocthmasical Calicuwaioms.
AdditHom
SubstsaHom
nulA plicadiom
DivSioT)
oduo
ov
Co-effiecient)
Divisí = l2 5
nt a b»c
loa div
CITSeTC
value in
pointf " ente a,b
Scanf Zd 7d a,&b)
C atb a b is % d1D C)
AddiHio of
primt C
C a-b) Zd \m C)3
primtf C SubStiation of
abis
C a*b d \" C)
Pim+f C"
Mulfipicasiom of alb is
dvOlb ab is /t 1 div)
C Division of
primf
C a/,b3 1n'> e)
C Modulp of aib is d
Priptf
gttht3
oupu s
Entei a bs Valu S
AddiHom o a b íS 1
Subtrattion of a, b is 3
5(S
ofab is 10
multi plitasiom
Div of ab 1s 5
modud 0 ab is o)5 2
elaHona oPeTakoy CCompaiS i0 n operatoy )
The Relaioma dpeady a used to CompaR
Operaty 6L alßo Called ay
the opeendss. These
CompaTiSiom operaftg
*lessham L
*reaterthan
lesstha m oi equa
*areaestham 07 equa
not equad = (o7)2>
equal to
void main)
imt a b, Tes3
clSCTC)9
pimt "£ntes aib values m")
Scanf (.d 1d a,4b);
d m (ae b))
pointf("a lessthanb
than tquab ).d \n ,(a=b))
pif a less
ch3
3
uwputs
aa b Valuey
Enter
b
a less -tham
lessthan os equal tob
a grectesthamb
a qseaeytnan o7 equal to b
A mot equals +o b
quals to b
3 Logical opeia8y
* Jogica and
dogicad07
OOt
Studnt maks.
CH>=35) & (e =35) 3(M>:35)
t35)43
Sc=35) 33 ( So>=35)
2es at Pass
(E >*35) t (M>= 35)11
t>35))| (H>=35) |1
i
(SCS 35) 11 ( SO > = 35)
Uma OpeiadoS
C-Suppots *o pes of Uma opead dg
Tmcoement opesatdl Lt t)
becement operadd C-
s
Imyemen ope7atdu tt)
he SpeciFied Vouable Value
tadd4Ho
Enamples
int
i10+
Outputs
Decoement opeTaS C )3
Sulo Sact 5o the Specipied Vobliable
value
Easm Pe i=i-
i 20-
20
i-3
oupu 19
wTi4e a
Umna. openadTy 3
*Unc opernadd
#imclud e cStdio. hS
t include clonio.h>
mainC)
nt
ClTSC C
primtf C" Ente vaue m")
Scamf" z.d, )3
incsememt
1 vaue is , d AN 1)
value
outpur8 mtee
10 11
value is
CTement
Decremem alueis
DpeTao
ASsignment avaue
Sed to assigm
AsSigmment opeiadoy
o equaHon +o he Vasi able.
Basic assi4mmem
opena-õ iS
3 Muiplicai omagsigmmne
a 0
. Divisiom Assiammemt open at d
ie aalld
al=10 ASSígn mend openatd »
5 moduld
a a/%1d
assiammemt Openatõ
PToTam usfn
usimg
6w wnitea Operao
ASSiammemd
C a C)
primtf(" BasiC assiament 7d \7
Ct-a l»d \m, C
print(" Addiiom assianmmemt
C-=a93 my
SubsaHon assiqm emt d
pYntfC"
C=S
pim f( Multiplicaiom assigmmem %d m,J»
Cl a
orimtC Dfvisin assiamroemt% d \m
P
assiqmmem %d C)3
primt f Mbaulo
getch
Oupurs CAa
Basfc assiqm
memt
assiamment Cu
AcdHiom a
hacHom assiqmmo
Ca
Subs CKa 1
assiammem C= uul
mu+iplfcuiom
Div siom aSsiqm mem
0
modul0 ass iq mend C
Btwise operatö%8
6 poaiaming
C Bit-evel
Bitwise opey atos uSed
openatlg
C-Supp3ls +o follouoi mg Bituoise
OR
Bitwise lvgita
xop excuus
Btoise Jogtta
dogilal NOT Ccomplementdy opeaa
8it wise
bCd e f,9
3
imt a,
clssct
a 10,
b 12
C a&b3
d a}b
0a
b
primtf ("c value , d1 )3
ateh
3
acideznat w
a 30
5-
a a3-o
a Oo001010
a&b
a b
OOO0 000 ab
oO00 O
OO00 |1O0
QAb +
00 O O
00
6
-(m+) -C104 -1
C12t) =-133
(nt1)
Ship+ operao
1 Left Sid e
sid
bits 7owandsS
townd Jeft
moves all the
Specipied noo Hme
fo
to demomSHate ef+shifF+
nt a
CsSto)3
a 12433
printf ("a aue 1S/ d \m aj
gtcho
oudpur Vae is 6
proessfo eft shff+ a
a 12 23-
ac<l
ODTIO o
aa 2
OZ2
6+3 = u&
3
aL
32+64 6
Naue 12
12 2 2y
vaue*2
vaue Xy =12
acc3 = a6 Vale 12
Po a Specified m
mo.ofim
to demom Stratt Riglt shift
po0gTamm
P3wrte a
opay operasog*
Riqt shift
#imcude< Stdio -h
imcu de <Comío h>
tt
Void maim)
elscoC)
a 12>> 23
value ís % d Vm a 3
p?intf a
getcht
3
out pu 12
PrOLess
0 O
a-12 = OO0O
O 0
=ut2
a20 2413
Comtso Stru Ctu1eS m C Jomguags
is 4 Con trof the fiou)
The Stademem that used
iS Called Corntrol
D etetuhom of Proram
Structuse.
4. Seauuming5 onder whic
It ezctutes he StatementSin the
Sequencing 07der) Ome by one.
we have Specificd Cin
S+atement morre tham 6ne.
3t can't eecute
(Stco
Siomple-
Stadement iS used whem we Wamt to
it s he
t7ue heo
test aa Comdition hehe
comditom 1s alse hen
hen
0to
3oto Statenemts,
Stobp.
0tD
flowchants
Syntaz g
Comd)
(ond)
Stat 4
S+ad 2
Stat4
Stat
Sto
Stop
auitea pTo gTam t demomS ae simple-1
#imclude< Stdio.h
#imelu dez Comio. h>
void moim
CITsCC3
n")3
pTintf (" Enterou o-ge
Scan( 4d &age)s
fCages=u8)
ave eligible o vote m");
ppintf C Jou
Simple 1F prognam");
printf (" This is
3
oudputs
yous a
ente
are eligible fo vote
Jou
his is simple FProgram
Entes youd aq
10
imt markS3
CirsCL)3 \m")3
Student markS
intf (" Entes Zman ks)
SComfC"7.0",
ifmoTKS >0)
ae uasiied m")3
rintt " Hou
3
etchl3
3
Outpu
mden sud emt mar KS
us
gou arse auallfied
Eed Stud em mas k's
3
Rwite a Program to aCce pt epersom age
displag o
fpersom age is above Go
Ose etHaem
Semioy
mt
clsscC3 pe Som age \m),
printf " Cmten
Scamf C %3", > ag
1(ag e>=66)
C" You CAne Senios CHaenm")
printf
getcht
3
Output:
EmiCs
60
Semio CrHaem
else Conditiom 1s TZUe hen
The gívem
, 1 Comdition
Caecte the f
Cecuhe blocc Statements
then go enecte he else bloCk
1Sfalse he
Stactemmemt.
Syotan Plowchst
T Ccomd
stat 4
Stat 2
T F
3
StatA
else Stat
Sta 3 Stat
Stat 4 Stad
write a program to demom s+öate f-else
H imclude 2Stdio h>
imclude < omio h>
Void maiml)
mt
cl7ScO3
poimtfC Fnes you1 cge n")
StantC %dage
if Cage > =1{)
ase eigible fo vote \m")3
pintf (tou
else
Jou cae Tot gible fo7 vote m)
pointf ("
3
gcht3
Outpars Emted yous aqe
elfgble fot oe
Entes Hous aqe
mt
ClTS 3
Point" Pnteoa numbt \m")
S cam " % d", &m)
outputs
Mumbe
s a evem umbe
Ente a DUTmbeyN
1
Tt 1Saodd mumober
(aa) wite a poogTamt accept a mum be amd
detenminé d ohethev + ?s posiHve 0 neaatve,
Hincude cStdio. h>
ttimeludec Comio. h>
vofd maim()
imt n3
ClTSCTC
else
C"T+ îsS a meqanue
mum bei \D)
P7intf
3
gtthl
3
Oukpu Emte a mumbe?
iS a posHve numbey
T
Cmn a mum be
1s aneawive muober
to accept two mumbeTS
wite a progTam
maninum o Hhe R
amd dtesmined
MumbeTS
Hincude <Stdio.h
#imclude<Conio- h>
void mimt)
int a b
C" enter 4 mum bes m")3
print
Scam"7,d" 3a9
pnfntf (" ent 2nd onumbe m)
ftasb)
print Ca is maimum \m")
3
else
printf (b ismmanumum \m")
R+cht)
3
outpu
f-elseelse if-else t adders
cas
2t isused peformed muuH pl
to
Statememt Tha
h
denemt ComditionsTn this
ome Comditiom amd muliple else if
is loc
Comdi tions and Ome else
Plowchasut
Symtan
Stt
-if(tond 4)
T 4
Stat 4 Cond
TStat
Stal 2
Stad 23
3
else if(tom d 1)
T
Stat 3 1Stod2
Cond2 Stad
Stat u
Ccomd 3
else
Stat 53 Sted s
Stat 63
Stat 6
else T
Stat 1
3
(StoP)
umite noam to demom stafe -else -1f-ete ?
addey
t mclude< Stdio h
include Comio h>
void maimty
int aib
ClaSCa C
\m")3S
plntf " Enten ab Values
Scamt( d " &a,b
else f Cla)
pint ("b is maimum m")3
else
getcht)
output3 Pm a, b valuey
a is mani mu
Emt a b valuS
Both aTe quad
Cmtt o b Valuey
bis madimu m
a Pogra) toaCcept* amum bey amd detemned
32-wite
uhethe 3 1S +ve, ve zero.
#imclude<Stdio.h
+imclude zcomio. h
Vojd ncd nd)
ClscO
P7imtfC"Enter o vad mum be s m
Scamf L2a&m3
m>o
primtf ( "+ is a +ve um bevAmD
else 1 (m20)
acht3
3
OupuS £mtes a mumbe
+ iS a 270
Cmter a mumbe
2
1S a ve Mumbe
Enter numbed
T is a +Ve num be
manksS
33 wie a PDTamm u aCc ep aS-udm
TeSuLE
Subjects amd dekr nined
nabove
folloong Crtes ia
.
based om
Maiks Resul
above Lo0 mvaild masks
DistimcHom
66 to 6a ast clasS
tfmcludecStdio.h>
tincludec comio. h>
Noid maiml
mtmm
clostt)
man ks m")S
pvinf ("Entti
Scamf ((" %d" , m)3
f(m>iDO )
pintf CImvaild oas kS \");
3
else ie Cm>-70)
primtfC DistincRom"),
3
else
pointf " Fisst elass 1n" )}
else P (m> 50)
else
printf (" Far"3
getcht 3
3
outpu»Pnted maTks
56
Secomd class
7 Emte7 masks
2
fail
Emte magks
Thisd class
Lmero mOF S
lnVaild mair3
OstincH o)
LOTt a pogram to acept Product mame 3
compute bi Ambumt dscoumt
rieauamity
bastd on follouwimg t7itaia,
aoove 2obo beow 50Do
7tBiU amount is
heTate of dfscoum is lo7.
#9mclude Stdio.h>
mcludeclomi o.hy
NOid omaimt)
imt P, , b,d,3
discoum
f-imalLiy
eha Pmame fa0]
clsOS
pTimtf("*** A mupamna Hypes manket * ** m");
Prm(enter product name \m")3
Scanf" 7S", GPmame)3
prnt " Entes ouan Hty 1m"3
Scanf C,a' 44)s
printtEmtes pce 13
ScanfJ,a', &P);
b P
J
prim t **Anupamma Hypen Mar ket *
print ("** vaTni Road, N2B * * n3
printf ("productname
printf"7S It
\t
,Quamity \t pice Amt \m")3
%d \t /.d
d \t n
Pname, P. b) ,
if Cb>10000)
ppintf " you discoumt is 20/. \3
d b* 0.20
3
else 1 b> 5000)
printf Yous discoumt is
3 d bi o. 15
else if Cb>2000)
Printf (
printf
printf "
You
You
TOtas
i
discoumt is d
Yoy fimad
%d
bili d
,
V°,
m f)
b;
d)5
Eme auam Hh
Pmten
belse Stat
Sta 53 Stat 2
Stat 6
Sto5
S+at
(Stop
pogan to accept a mum bed Omd
5write a
void maim (
Cl5SCTC)3
iFmo
i(ma10 )
else
gtcht
OutputS Emk a mum bed
imt pm, M3
csc3
pintf(" Cmtes lims enamination moanks \m")
Scamf (7d Pm)
Pmsso)
pinti (" Emies the
maim Aam maks 1
Scamf("/.d',
&mm)
fComm> 50)
else
1m
printf C Your mot Select ed
else
Your disQualifí ed in prlims \mJ3
printf (
gttcht3
Outpus
6 Switch 3
Selech a Sing e Stalememt
Suoi+ch is used to
Switchchoice)
Case 4 Sta 3
Stat 23
bTeak
Case2 Stat3
Stat
breal
CaSe3 Stat53
Stat6
bTeaks
default: Stat 73
3
wwite a p0Tia) to demom stratu Suoitch
#onclude<Stdio.h>
+ionclu de <omio.b>
Void maim
cha ch3
\m")3
Pm1f ( Enter ony chasacker
Scam (%.c", 2ch3
Switch &eh)
Case'A'
C"A fo Omdrdid 1n
Case 'as printf
bTeak
Case'B'
Case'b: primt} ("B fos 8tutootn"J
bseal
Case'c
Case'' printf(" fo7 Compute 3
Teal
Cose'D's
case'd' pintf C" D for digîtal ")
bveac
default printf (" Invafld choice")3
Juch3
Output
to demomStrate aithmaHc
8write a progam
opesodi oms by usimg Soitch:
Himclude 2Stdio h>
include 2tomio- h>
loa es
int a b
c'ha ch
cl7sto3
a b values
pimtf " Ent 1m");
flush (Stdin)
Scamf " %C, &ch)
Swsteh Cch)
Case
pointf ("add of a.b is /f"Tes)
boeak
Case yeSa- 6
3
pointe C Sulo of ab is }Tes)
bea
Case* es= a*b
poin+f C" Mul of ab 1s 7.f, aes°;
bTe al3
lb
Case ' TeS al
príntf C" Dív b i5 Fzes)
bvear
case TeS= a7sb2
Pintf L modulo of ab is f Tes
brear
default printf Cyous tmteded a nvafid
choite pls tsy again
3ueko
3
Oulput s8
Sysh
#ircludeL Stdio.h>
t fmcudeclomio.h
Void maint)
int oph0m
cso3
prinif to
welcome
pinttEnie o1 8.Tec Info m")
primif ent 2 fon MoTeb Tmfo I")3
Socar
primtfC enHer YouT option m");
SCom
d optíon )2
Sa0
Switch oPtfomn)
B.Tec ClasSTo o a e
Case 1 3 pmif he
NOTHblock (")3
Jocared at
break?
CaSe 2 prmtf [ The M1tc class TOon age
6eak
class zoom a7e
Ca se 3 pdint "The MBA
nt a3
cha ch3
pimtf C ente nteaey m")3
Scan d a)3
fPuS o CStdim) Cleom the ilr bufes
primt ("emte a Chaact7 m")j
Scant C" %d", 4ch);
primtP The mumbe is %d \n", a)
printf ' he chad 1S
7c \ ch)
gecht
6utpurs
gotd fs a un (ondi Honalumpin9 Staemme ,
the Comholjumps fom one patof the Prbaam
|to amothes paot of the pronam eHhes fo7uwand
07 backwagd
b usin
Sim9 qoto
-9pto Paot
poni Stat 3 3
Stat 4
goto pat 33 BacewaTd
fonuay d
emd Stat 1
oto pant S+at 1
Sta 2
goto pant 2
pan t3 Stoat 5
Std6
uto end
pute addiion of 2
oga to Com
wte a
goto
mumberS bustng
#nclude<Stdio.h>
+imclude Comí o. h>
void main)
int ai b:C
clase)
goto impu3
Outpu:
primtHC" add of ab is 1 1n, c):
dotoeTd
prDees
C atb
oto ouput;
imput:
p?intf ("Emtes a, b values 1n')s
Scamf C"d T. d"> a, gb);
got processg
end
primtt CThís íS demo om 2 to ")
gttch
goto.
u wite a poDga Suappina with
imt a b, tumP
cl7sC)5
3ob imputs
before valu es
ab \mJ
poimtfLBefore Swappmg
printf C"a =% d \m" a);
printf (b 7.d m b;
suDop
otd
Soap
emp a3
temPb
Jofo ouputs
impu
Prin+f C Em ab Vaues m")
8oto befo%e
6utput 3
vau es m
pint ( AH SuDappin ab
print ad \m a3
primt f Cb / d b
3oto end
emd Soappimg 1m 3
is
pTintf Ct this
etht
3
values
Ouputsene a b
20
30
before swappín
a 20
-30
Atus Sudappig
a30
Suoappin
Suoappíng
wTi a P3oram to demomstIatee
of 2 mumbe1.
maim)
imt a b, temp 3
elsscc
printf C"Emes aib Values \n")
Scamf %d %d", 4a. tb)
printf before Suap Ping1 a b vales m")
print %d In a a
printf b d 1 b)
temp a
a-b3
btemp3 vasues 17")3
ab
pTintfAfter suapping
Print a= %d m a)3
print b %d m
b)
etcht3
3
Ouput n tes ab valu ey
30
ttone SuopPiMY
a 0
Afte Suuppimg
a-30
20
ernor Shro Squaoe
aproom
nurnbe
#incud ezStdio- h>
h>
4 incude<tomio
Himclude Lmath.h>
maim
mt num, Yes
printf Ente a
erch C
elrscC33
8pto (20, 30)3
printf (" weitome );
"
cht
3
Ouput el Corm.
oopS
Joops aTe alo Called as 1tteraive
Statememts doops aAre used to eecue
StatememtS mulHple timeg
Same
C Supponts toD following ooPS
. while Joop
do-while dvop
3 fo-doop
A. TniHzaion 1s
Nalue o he Vaia1e
ASS mim
xefeisto m H3afom
Imiememt: C++E)
to he CuTTen E
t Tefers 4o adding
vami able Value
i= 20
=20+
3 DeLiemen C-
Tepen s toD
Sulsstsae Hng
Cudet Vani alle Vclue
the
20 1-13
20 1
19
guwww.e
while doop
am emtoy Comtsolled JooP
It is
T7ue" then Bocdy of the Jodp
whem ion is
Comd
Syntans Plouchogt
ini Halzafiom
uhile Comdi h 0n
wmelom4)
Stor
Stat 2
T
Inte Dese
Stat 4
Stas
Stop)
/ fme ec
(Shof
wTitea ProTiamm print ou ame to Hme
whtle do0p 9
Lsing
inctudecstdio h
imclude 2comio.hs
void mounC)
mt3
Closcoco
hile (iL=10)
3
+
etch
3
Outpufs No AnupamÁ
ew Anupam
New Amupama
P AmupaML
Neu AmupaMa
Neu A MupaMa
NeD AmupenMa
New Amupamma
Anupam
Nu Amupama
uwrite a proqTam to pint 10oonumbenS
Hincude< Stdio h>.
timclu de <comio h
woid mem
-43
clysctj
while L1L=l00)
printf ("%d m°, 1)
++3
3
qech
3
Oupu
wite a poTia) to Pnt 4 to n Dum be7
#include<Stdio- hz
1meludeLComio h
VOid maänl)
imt 1n3
cTSCOO3
pinif Enter m Value \m"b3
Sconf (" hd", Zn)}
ohile (iL=n)
ppintf C"%a",
D
3
gech
3
2
13
5
wite a Sroqsom to dfs plainj
Mum be6S.
Rmcude c Stdio. h>
+ne lude 2 Comio.h>
int ,n?
Chsu
printf 'Enes m Value 1n)
Stamf ( %d, gn)
while( i2 =n )
pintfC"2à D;
++
gch 3
3
ouwputs Emte nvolue
8) wTite a pTDgram Odd mumber.
imclude Stdio ho
h>
#mclude 2lomio
void mcun
Clo SCo0
uoile i2n)
= ifi72!=0
getcht
3
Emte n Valu
Oupu Em nvalue2
A
wte a PTogTarn pint m+o 4
mclude 2Stdio.h>
intudeccomio. h
maln)
im
while ( i> =1)
3tch
3
Oupuls ent n Valuue
wte a diplaing to neven
mumbs wit amothe mtno d 9
Cond 6dd
4tincude <Ctdio.h
Hicude2Comio. h
vDid maint)
ctrsCC°G
pTintf C"Emtes nvalue m')3
Stamf("/%d", Zn)
(odd
-23 (even)
while (i2-n)
3
+23
getcht
3
Oulpu mtes n Value
6 5
wite a pogToam to pint Sum ava o 4 to
mumbeT S.
Hinctu decStdio h
h>
imclu de <tonio
maiml
. Sum
float a
Clsc3
value m")3
piintfl" ent
Scamf L 7%d 4T)3
i1
Su 0D
while iLe m)
Sum Sum+i3
++
pintf C Sum D mumbenS is 1m", Sum)2
gtcht
Srpur9 Emte valu e
Sum of numberS IS 55
au of mumbtiS S 5. 55
do-while loops
be evecutad
.Initilazaion wl
be Ciecuked
ot the doop wil
2 Boy
Updabiom (Tntel Dec7e)
iniH3akion
do /iit
/Stat
Stad 2;
SHat
Tme Decse
Imepece
wh'le ltomd)
Klondition
Stof
print mumberS us1n
5 wnite a Piogsamt
do-while loop.
+inctude<stdi0 h>
+mclude 2Comio h>
Void maúnl)
do
pointf"%d \m", i);
while ( i2 = 100)7
gtchb
2
5 woite a pro nam to pnt 4to MumbesS
void maint
nti,n
Clnscs3
Emte m value 1m ")5
pintf
Stan /d", 4n)
1
printf %d \n",i;
while (iL= n)
10
numbes
Pbganm dfsplaying1 tom even
imeludec Stdi oh
Hin clude < tonio. h
v0id maint
mt 1, m3
clsc (
value \m
printf C emtcr
do
iPC/% 2*0)
printf hd \,i)3
whtle ( iL = m)3
ech
ouputs Emtes m Value
10
program o print to n numbtns
Odd numbtns
55 wvite a
while Joop
USsing do
4include<stdio.h
include< omio. h
void aint)
nt ,m3
do
Ch 2 1)
pintf d\m", i)3
oh?leiz=D)3
etht3
imclude z Std1o hy
timclude clomio h
VDTd main ()
19mt i,n
ClTSC
do
prin +f ,d m", i)
--
while ( t> =1)
gtchc
3
Ouput ne MNalue
10
príntSurm 3 ag
o
wTte a progTam
Joop
ohileboP
mumb ers by using do
tinclude <Stdio.h
n clu de ztonio.h>
VDid maimt
Rnt i Sum
loa ag3
elsSC C3
PYinfC Cnits mvaAe \m)
Scomf C %a"&m)3
-1
9um 2 03
do
3
while (íL =n)
Primtf Sum of numbens is /,a \D" Summ ) 3
av cfloat) sum m
pntf nummbeAS 15
f 1m QuG
getch
fo7 JooP
Ccomtod led
S am m
pat uoTU) be ae tute d
4 miHi3atfio
d
Con dirom wilh be tiecte
oDp
Comdi Hom is 4ue body of the
3 11
be ezecued
pdare imCseMmu De co e t
4then
be ecued
5 Agan Condi fom uoi
6 It repeate d StEP
Stp 3 +otep 5
ComesS Out of the
T COTmdiHon alse ContsolCo
Symte
Stat-A
Stat 2 T
Decse
CTe
wsite a poognam to print to m mumbensb4
asing fo7 Jodp.
HimcludecStdio h ime
+mclude 2 comio hy
Void matmd)
int,n
ClTsCot)3
printf (" entey n Mum ber \m)9
Scanf ("/, d', .n)
fo (1 14 m 1++)
getchc
3
Outputs EnHer mmum be
15
10
13
to1 numbeby
5 writea progTam o
usfmgdon bop
4includec Stdio h
H include <(omio.h>
void maim t)
ciosct9
pintf (' Enteo a numbe m")
pointf C"%dm', )
3
9tch t
3
Outputs
10
1
to pint evem mumbes
wTite a p1ogmam
6
by usn foloDP
Himclude cStdio h>
+inc lude comio. h>
void müml )
mt 1,m
\m")
printf t" Enten n Mumbes
SCamf C%d, &n)
Ci%2 =o)
primtf ("%d m",i
gtcht
Outpu
Oupu
Enten nmube
5
PrograM to poimt Sum of dfits
ik a
Cxample 23
4+2-t 3 G
Reverse 0F mumber.
numbe.
wite a pogam to pint
emple: 123 /P
321 lP
palindTDMe mumbes
PrOqT am to point A
3- wTite C
Lample: 121 P
12- P
Ams0
num be
wTite aprogam
Enamp)e 53 +5+3)S
+125 +2
53
OP iI be Same givem num be?
+o fibonacc Sentey
5 wite a og3m
esumple O 2)
2 3 8 13
e M/» 10
Sum: SuM +eTm
ComprlaHOTY pabdt?
Sum0
123 0) T
while
eM 123 / 1D 0) 123 (12
120
De m
Sum t Tem
Sum
3
Ot3 Sun
nlo - n 123/1o l0) 123(12-3
n12 3 3
12 30
while m> b)
12>oT
1o)12
e
em= 2
Sum=Sum+Tem
3t2 5
M
e 1o) 12 0.2
O
20
while tM>o)
T
10)
Tem 10
Sum- 5+ 6 Sum =6
100.5
Sum 0
outpuf Emte a num b
1-0
Sum 0
while (120 >o)
m12
0
Sum
wile 12 >0 )
T
em 12 10 1)20
to)12 0
1210 2
Sun 0
while Ci70)
ven 1/%10
1
cioSC70
pintf (" enes mumbs \m")
Scan f C d" n)3
while m>d)
ev (7e v) * 10 t7e m
U5I0 6 u5.4
m:4S6
MuS>0
Tev: 0 10) us (
6e 5
eU 6*10 45
Tev G5
us Io -5 =u
Tev 65*lD +9
65
Tev
654
(63 cote a progna to dlehevrine numbe
ive
is palindoome Mumb e 01 nt
melude cStdio h
imclude ctomio.hp
v0id maínt)
ev CTev) 10 +7e)
3
1 em p == 7e v)
else
no4 pali ncaom mume )
gekcho;
nt abi C,
ClSCTC)3
a0
ba
fo C
1 = m- 23 í++)
C a+b3
printf %d \E, C)
a=b
C3
qtchc
O 23
mumbe
6s wite a pom t deted mine iven
1S pime 01 mot
#imclud ezStdio. h
4 imclude <tomio h
void mmaim )
mt m, C
i
CloSCC
C03
13
=
while (iL m)
C++
14+
i CC2)
prime Mumbe1")
printf ( It S
else
pnintf (" D is a mot pime mumbe
gecht
Cwite a piogsam to deteimine ven
i number
s Amshomg numbd O Mot.
+imcludezStdio- h
+imc lude c comío.h>
Void moint
Sum b
whiletn 7D)
ftemp == Sum)
CAse
prtmtt (4 1S mot a AmSHrom um be7 ")
gtch
3
Nested docps
with a JDop isalled as neStcd
Joop fn
F
S+o
Symtas P
foT (iit Comd g
TmeTe DeCTe)) F
Stat A
S+ot 2
3
3
ollowing oP
wnitewrite a ram to dfsplau
13 14 15
12
19 20 2-1 mo of oS 6
16 7 18
imt , C, i J9
pimtf("EmtC3 mo. of
prin /m")
fo1 C
1 j4 fs +t)
poimtf " 7a)t,c)
3 3
Jucht
C wte a pTbgram display Sollowing olP
2
3 3
3
5 5
5 5
imcludezstdio.h
Hfmiludec comío. h>
void maim)
imt m, i 3
clsC3
no. of TowS 1M ")3
Pinti (" Entes
Scomf U 7d" m
PTntf("}n")3
3++)
for(j=1 Í=13
gtcht
(640te a Poranm to displayfotooin Oupu
ouput
2 3
2 3
2 3
2 3 5
Prinf C /m")3
for(j-1 j4=í j++)
tch)
3
dísplaying he followimg
wite a pog 4o
OutPu
H1nclude< Stdio.hz
t+imcldec comio. h>
oi d maim )
imtmT ij3
ClSC79
no. of 0s \)
primtf("Enkd
Scam C"%d" T)3
gedcht
d
Value s
-
ATra
ATTau43
o data
Array is a collectiom of Stnila type
vaialle C-Suppots
whick stoes daa in a Sim gle
to follosima yPes of Aa
single Dimem Siomad ATTaLy
emo Siaes
NO.DP bytes pe a datay pe
NO.O lemen ts*
lo bytes
Tota meTp Siae s
3S ao ty
A. Dinami
c 1nliaaHons
ASSiamiTmg Vaues *0 A7 au a the me o
declaiodiom is Tefers 40 Dinami c nitHli2aion
Symta
V2 V3 Vn
Dala ype aTaymam e LJ 2V
ELamples
wamt Stor e 30, 1o0 im Va7ialle
Stoes dada 9
HoD aTa
ucin9 mde
by
ArTa StoTes data o
imde StoUs
Stots m
from
f0
Sub Sipt numbens, the
Cze70).
3D
iLJ
(2j 100
Direct ASSiqnment
efeing t's
ASsigimg vaues 1b Assiaoment
Sis
mumbl7S knouom Pirect
imde
Sumtar
,
Arpaymame SuoS(ipHonj= value
Fo enam le
uwGmt to Stoge 2.60 300 10 20
variable muM
mt mum Lu3
um LO 200
muCJ 30D
num[J 0
Mum f 31 20
at umtime
3
Values
Assi
nin
Valuesto AnTay unime
at umtime
we Cam ASS iqm
Void maimty
cost
primtf Emter how mam values you want
to um 1m");
sCam 7»d'» Zs2)
fo (i=o iLS2 i++)
gecht
Outpurs
womt to mum
Emte hoo mam vauesS
e
Emtes SValu
LOO
2nd value
Emte
200
mtes 37d Vau e
The valueg
00
200
wwite a proqsam tv demom Srate chasacte
aYTay
vdid maim
imS2
Cha ch tiobJ
clsCot
pimt (" Emle hou mamu chons ou wm
to Stoe m")j
Scamf " 7.d", s2
printf ( Enhen chars into a9ay n'")
i4s2 it+)
o7 Ci-0
qetch ()3
3
Dutput
m amuy chars wamt Fo Store
Pmten hou
aCtept Values imto
itea poqram to
moninun Valu ey
minimum Omd
and fn d
ofthat 00L
#imctude <Stdfo. h>
h>
include 2 Conio.
oid maimt)
marj
ent Sz, 1, MuTn ltoo3, min
clisCTt93
p7imtf Ene no mamy mumbeIS ou
OCmt StoTe n"J3
Scan C" %d° SS2),
printf L" Entt numbe1S
mi= mumlo3
ma mUm LoJ;
printf C"\D The
Oo mumbens u m)3
O7 10 fLS2 3 i++)
1Comim> mum Ci3)
mi mum [3
i (man c mumCi3 )
maL mu LJ3
pnimtf(" %d\t" mumC3)
3
mimimum Valu e im
pimtF m he
gCh
3
demonShati charccfe ars.
atephm roup o chanacters 6'ne by
displain1 me by on
imttude <Stdio-h>
lude <tomio.h>
void imt)
cha ch Do3s
mt s2
How mam ChanacteoS tou wam
printf ("
to Stdre mum 1m'")S
Jach t
Sring ava
Sting S a Collection of c hotacters.
main)
cha7 stC2533
clsca)
Print Emte a String
ets(S+
Puts cst)3
tcho
3
Emtes a Sin
ArTa (2D-aTT
TwO Dmensioma
data w be StDTed
Stoved 1
Twb Dimensiona avra
ow Colu ise.
the fonm o able t.e
Declagatiom of 20- a7a
Symtans
datatype Graymane LmJlnc73
Eamplts column
MC- mo Of
mt num[23l233
Tm aloove eample m is 2D-aDia
i tha we Ca stoYe 4 elements
TOS&
1.e Colu mD.
MemaSíaes
NO. of elememtS no o tes per data
NO elemen ts =
NO. OF elenent+S =
Mendysf2e ubs
Mem Si2e8 lbjcs
ASS aming Vau ts to anTa
we COm assía ValueS 3 was
4. Dímamic imitilizadfom
. Disect assianTDemt
3. ASSimin values a umtime.
m
Dimamic HlaHons
Symta
daatype aviaymam e C3C3 = S7t 71 C,
2 C
C2
Fo etanple Iwamt Stoe
30 50
he wi be StoTed 2D GT O
aTa
mderSubSori pt StaTt faom O
mat tJ[o 30
matJJ 50
Disect aSinments
direct asSianMeN E wC assign
Stau-
Values t aa Gmde Substipt
fhom o) 1fenime t's sou numbe7
COlumm nun be.
Symtez s
OsTaumame ow moj colmo Value
enamples
wamtF StoseFollouinmg data ín
6 36
num C2J123
mum Co3 Lo3 5
u [oJLJ 5
mm CIJLS 36
SSying values at um me
m
we ca assigmin ValuS to aTT au at Tum
clsCC3
pimfC" Eme mo. o 7os m")g-
ScamfC% d" &m)
cols \m)
PTintf C" Enie mo.f
Scam C %a" 4nc)
PrinttC"Emtes data into mat 1m")
fo O; imi 1+t)
WI)
mimtf(% dit", matl
ch
Outpul
Eme mo o oS
Emtt no o ols
Emte 4 0 4 Col
5
2 Co
Emtti
2 0 Co (
Ent
5
Enti 2eo
The Oy Jalues
5 36
poissaie
matnia
ColummS
pDse cams
T9amspose
TamS eveise i.e, 70ws d
Columms o DOLOS
maimC)
12n7 i++)
fonio,
Pimi C
n The ma values afted 47anspose are \n
Printf Cyn")3
3chd)
outpug
Emte n0-0f TOwS
25
2 Co
buD 1Co
Emted
Emteo 20uD 2C61
36
The at values afte t7anspoSe
a5
maimc)
3
* ew
for(0 3 j4Sz S+ +)
prin \n")3
3
mat 4am d mat 2 Values
PTintfC m Sum of
ase ln" )
pvrintf \m") 3
fo (-o3 4S7 ++
SumL13 L mat LJTIJ1L
+ mat [ij LJ3
eteht
3
Outpur
#mks o D S2e o mat 1 amd mat 2
5
Co
5
2 Col
Emer 2 ICo
5
Emtes 2 70uw to
36
Cmat 4 values a1ee
5 6¥
5 3
Emten ma 2 Valtes a
1Co)
emei
5
2Co)
EnHe 22 iCo)
Cmt 2 (o
a5
ma 2 Valuly ae
20
Su of amd ma 2
3D
write aprDgTaM to dumom StTate muJiplicadrom
o maia
maimC)
o7 o jSZ3 jt+)
%d col \m +j*1)3
poimf C'emte d 90w
Scan C
h d", mass I13 LI3)
3
\m")
pmimtf C°"
Entes Values into mat 2
fo -o 3
Jsz jtt)
primtp Cm")3
J++)
fo (=03 J2Sz 3
3
pintrC n Ma 2 values ae m")3
printf C"m")
fon (i05 34s2 3i+)
echc
Duputs
P7edefimed fumctioms3
The pe-defined fumdioms e Cate 9o7ised
mto follooim tur
inpt 3 Out umcHoms.
Pnimtf Seamt )
putChatl -chaal
puts c etSC) Co
put w() +imclude"Stdio h
fpnimtfL)fscamt )
1 Comsole fm put out put funcHomS
nclud eLConio.h>
J-cho3
fus (S4 dim)
atw ne Homs
POw
Shin9 Hamd ling fume Homs
StTev ( St eat
Sh em ) St p) #mcludezStrim 3 h
SM TOPO S sPS)
S wT )
chaaattt7 hanmdlina fum cHom.
salpha , s digH Hncude 2chqe h>
slowaTC ) iS uppes)
tolowe?l) touppeat
9memgy aluotaHonumthon
mallo CC
Hinclude cauLoC h>
TeadlbCC
S
loat
clS Co?
ges Sqt(25),
pmttCThe SaTt of hummbea S
/f \m eS)
ges = pou (a.u)3
oin C
absE10)
The a pooei 4 S . m" 1es)
omint CThe ales
df-0 15
n", 1es);
m C the o Vau 9s
m,es);
Ves SinC)
primtf (N he sim value iS 1 7s)
getchc
3
Outputg
of um beT iS 55, O0o0D
00o oDD
The Sq+
S 16. OO DdOO
The2 powe o 4
0 O6006 0
The abS o
O. Oo006D
Ahe Value
ont Sz9
chan St2oJ 3
ClSCTC)3
pyimdf (" En e a Shing m")
tts St3
puts (S+)
putsC Syevc S+))
putS ( Cin dev C" hai")S
put S C Stn up? ( hllo")3
ANDPA M CoMPUTE PS"J]
put s (St Jw("
den ( ComPoTEPS ")3
Sz Sh
printt C" The mo. ofChas ae ha 17, ,
2)
Sz= St cmp Compue7""Laptop S
1s d 1m Sz)
Printf ( The Cmp value
purs (St+TCat ("Telamgam a', State" )) "
qecht
3
oudputs
Emte a Shsimg
heuo
heuo
Oeleh
iah
HELLO
amupama ComputeTS
The no uf e haf ae a
wTite
oa to aCcept gharactes
h getcha)2
Fisalpha cchi) )
1f(isldwe chi) )
ch ch2 touppeslch2)
pu chuMch2)
eka else
ch2 =totowec h4)3
putchao Cch2)
3
3
else f (is digt Cch4))
a mumben \m
Printf " Ttis
else
3
qucht3
3
butputs
User-defimed fumeHomS
USes depime fumcioms ae defmed 6 he
uses based om Thei requirememts
the followina Synta to defime a
defined functfom
Syntaa
Teturntype funciom mam e
elTsc 3
mydetails C)3
Primtf ( hello 1m")3
( this fs demo poqTm \m")
imtf
mydetails )3
my detei lsto
getch
3
mydetai ls c
mydetalsc)
k.sbufamya 1)
printf M name
C fs
printf CMCA m
pofnt C
Nishitha p Colege
pointf N2B")3
Save Olooveile în C
C imclud e oldes
lename, h
inelude Sdio.ho
H clude Comio hy
mclu decale mame. h>
maiml)
clSCo C3
pvinf C hello")
mydetar]S )3
getcht3
3
Output- hetlo
Mameis k. Sou
McA
isnitha P Colleg e
N2B
Retugn Feywod&-
to Pass he value
valup
ketun KeywoYd is used
es
cloSc)3 Sumcion Call
res Squase)
printf he Square o he nD ish d \n Tes);
qercht)
Squase C)
Teuin deffnatio
n s oimo quc e
Dutput
CHe a mumbe
Symta
deusntype Fummame (aTgum emtS)
fumcti om Ca
umnamme CagqumenS)
wte a PTO 3am to demmm sthatt fum c4fom
with arqum emts
maim C)
clisCT)3
Pintf C" Emtera bvaluuts m)j
Scamt" d a" a, b);
Sun Ca b)3
getcht
pointf C Sum o ab is d
Output
CmHe Naues
220
Su of ab s 3D
wnitea Pog am to demom Shat fumchom
wi agumems eu7n kajuoo d.
Maim C)
int a b eS 3
ClTSCoC)3
pTintf (" enter ab Values m
Scamf C %d %d" ga, 8b)3
ses Sum ai b)3
printt l Sum of ab is n 5
Tes Sub Catb)3
of is d 1 es)
pimtf Sus alb
9etch3
Sum md a Jnt
2
C t4
us m C
mb)
3
Fumcio ith poototype 3-
Eample g
imt ab
float s
loat divCint, imt)
pii " entes abVaues m")
Scan C Y.d d a4b)
Tes div Ca b)
pnimtf C"
he div ot ab is Jf\m es
gctch
a, imt b)
loat div(imt
float es
S Celoat) ala
Tetum 7es
Outpu 3-
Re Cu SSive funcHom () Recunss?on
maimC)
clsSCC
PimtfCwelcome 1m")
maim C
1tcht
3 tse
maimC s callinq itsep.
above enample,
Jong m, 1es
ong fact Cint)y
clsC t)
pTintf C Entes Value m")
Scanf (%d3n)
TeS act (n)3
(" The fact of 9venmo. iS d m')7es);
mimif
getcht)
3
Cimt m)
Lomg fat
Som es3
(n O)
7tusnm es
3
Outputs
Stuctuses
Simila fype of date
T is a Colleciom of the
Datatype VaT-Mame
int empno3
emameL203
Cha
loat Sal
3
Struttuse oects
S a mStamts of
ofF
Ssuc tuse object
Stouctue +emplau
enanples
Shuc+
templat
Shuct SsHu
cha mame C20J
jmt Tollmo
float fee
maim
P
C" Ented fee \m")
Scamf C" /}° 432. fee);
pTimtf CThe Student detailS aTe m")
pritt Name t Roll D\E Pee (m")
primtfC",S \t ). d It %f \m°
SA. Tolno, SA Fee)
S4.name,
primtf C"/,S IE /%d \t %f \m"
S2.name S2.01n0, S2 Fee)
nei Táme
lo
Ente fee
000Soo
N
me Rolino fee
LoOO0 500
anil
l02 O0D
Sumil
03 lO00
Tahul
The ep detailsare
enam D
Sumi
02 Rad
tham UDíOm.
Umiom oe have
TD define
he place Of Stuc
wite a proqTam t denom strat
union
imtn03
cha ame [2o
main
nt Sz, i3
emp Li0oJ
um
A Ta of Structur e obje c
t demom Strate arST ay
wite a rogTam
Sructuie obfec
Stsuct
emo3
cha mame C20J3
maimt
int Sz, 19
emp e Lioo3
Shuc
csc9;.
("How mam emps data uwamtto
pontf
StOe 1n')2
Scamf C" %d ", & S2)
(entCemo I)
printf
Scam C . d" 4 eci3eno)
primt Ente name n")
Scamf C%s",etIJ.name)
fonCi-1 Sz 1+t
getcht)
3
Outputt
ou wcm to Store
Hou Mamy ems dafa
3 dtd
Emter4 emP
10
name
Ente
Sum)
2 emp data
Em
end
Pmtt 2mp
l02
2 m? NÁm
Pmte
Rahuul
f Y
pointer S dioided into mo 0f
coTmpure mem s
The OCcupies byte of-
HCiHons each pasHcíom
paN locat om
locaf
Comteuns a níque
mem ou amd
Called a addess ofthe vasí able.
Mum Les
Stores Stain9 addi ess o o
The poíntt
the vatíable
C
20
imt 20 lo2
oy
poimte StOTes
105
Staoing addyesS oF 106
Van iabl1e LO
a value fs 20
addness o a iS 10)
#)
use pojntez sS we hawe touse
we
add ess
P
VAiable lue
a 2D
1P 20
a 0
prog1om demomstno poimte7s.
write a