0% found this document useful (0 votes)
14 views

Language C Notes

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Language C Notes

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 192

C-Lamguag

Lamgua
IS a Commumícat e blw too
A Jamguage
ShaTe Some mfo maion.
eson s ohic Cam

A Jamquaqe 1s Commumieato7 o mediatdr

betweeD the entití es

Lamquaga is a classified into


a typesTha asa
4. Natural oamgua

pT0gsaNníng JLomgua

A. Natural domguuq8

Jamgu iS a Com mmumi cat


Natusa
betweem +wo PesorS.
Natusal Jamguag3 a Spokem amd itten

puopose

By NatUTa angua e Cam Comumi caM


wittw eacw Othe

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-%

meams we Cam primt the vaue


The A to 2 65 0)
a to 2 7 |22)
Symbols
=
* 1+ 3C3.
No primtab1 1 12
we can+ print he Vaule.

They OL Space CapS tal, P-

How to ind a ASCTT Nalue

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)

Secomd enen ation - Middle Aeve Iomguag


Xamguage.

veplaced he tsamsisty
Compuess
RmStmead fubeg
fvaccum
Tn Second
emesaion AssAssembly Jamguag
itmeraiion 197D 14so)

em Shemesatiom Jevel Aamguay


Hialu ama.
Com putens wee usima Ics
These
mom CompomeMt.
CImdeanaded Cir cufteTS) hag

amguan
English Jamqua Cormpil exs ias
mg Jamqua Techmics
PoO Tam
a+yoe
Algonithm
Plowc nant

Algonithm
The Stepby sTP pocessS to Complete a

task s kmouom agAlgo1ithm


Tn othes uwods Algonithm eens to the

Sequemce o StpS * acom plisw a task


eample
Algonitm Add?Hom of
wwite
amumnlbR
Step 4 Staro
hcdiioo C
Step2 nput
C atb
StP3 calicuwate Addi Rom
Step4 Displa AddiHon
Step 5 gtop.

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

algoithmm is Calle d Flow Chajt

The SymbolS used i flowchant

Symbol Namm Fumctiom

ova Am ovc eT SeMtS

a Stagt o emnd

ATTouOS Aline ?s a Commectox


hat ShowS elaiomshi P
blw the repres emtative
Shaps
paT alelogna) A payalelogram
Tepresemt im put
o1 oudpu Cilpo7oP

Rectamgl A Rectangle repiesents


C prOCess

Diammond A diamomd indicate


Rhooy a decisiom
Enamnple i s

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+

Step 4: Stant Stat)


Stepi 3mput a b, c d
CC
lp 4bc sd
|Sp3 d atb*
Stcp u displa
|SHp 5 St+op d-atb*c
/ dpiey d
SADp)
wwite a algovithm amd
da alo c hant
4o demmomStrate the Com putadiom pmoces of
Simple Imtest CS.T
Algovi thm PLoDc had
Step 4s Stat Star
Stepir PT,R
/lP PT R

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

amd CiT Cumfenemce ofCicle


Step 4 Stat
Pre VaRue , Radius
Shepa lp
C1cle aT7
Step CfaCumferente 0f
x IX 7
3.1u
Stepu Area f C7Cle TT

Displa cunersence of ciicle


ci
StEP 6 DiSPla Area ot Ciele
StOP

Flowchart St+at)
lP Pie value Rodus

Cfocumhence d Ciocle 1
2*3.IuAT*7

Aea
3-1uA *I

Displo cTcum foenie of iacle


Rsglay Area f Cincle 7

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

SHe pa imput &and b Zlp d4b


Sep3 ATea xb Are a dzb
STep 'pesimettn 2(+b) Peoimeded 2t
Step 5 ofspla hse
Displa Area
SHP 6 DSpla pesimete7
Stp Stop DISplay Peofmete

(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

ALGIOL Imteinaioma Committe


160
christopher Stsachey
1963 CP
67 BCPL Masim Ritchaids
kem thomSom
Denmis Rtchie
ANST C ANST Commite
1990 TSOC TSO Commit4e
StamdAT dCommitie
C Standand Committe

ALE0 Alqoihmic angage 4 Jamauaga)


CPL Combined PTOTamimg domguag
BcPL asic Combined progamnimg Somgiag
B B-Lomgua
C C-Lamuaq
ANSTC Ammenitan Nadioma Stamdased ImstRtudte

TSO C Imeimaional Stamcozed oqronzcion


Appltcadions 0 C-Jamguo
CJamguage wa used to Constu cthe
UNIX
finst operadínaSystem
peating SHSterm
sed to dewelop the
C- amquage 1S

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

The follouimg Steps ase uses o

Simple proqTa7
TO wTite a me Poaram pess

At+
maimC )

2
printf C" welcome to C-domquc

TD Save ab0V PToFam


COT F
Give the ilemam e filemame C
TO Compile apoITam
Alttc OT)F
T0 Rum eLLutiorm) pTDaram
Co Ctlt Pa
At+R
To nold 1give outpu
Alt t Fs5
enit om CEd?t3y
ALt +XJ
clsscs
closcoL) is a umcHOT , sed fo

elaan the Screem


*woie a proram by usim ClTsC7(O
uncHom.
neimt)

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 s used to emeTati a meuy in

t
t s used Gemeadta tab Spales
4 tab = 5 Spates
s usedHo he previ0us
Tt
the slashs

S uged Caroiaq TeuD

\a los) 0011
OUMa
TE S used esne ati beep

Calas m)

-osmfeed Symbo]
Tt S ued 8emeT ate

fomfeed Sym bol


- -\ Simgte Coae
- double Code

PTOgTamo
WTite
escape Sequermce.
maim
cliSCTC)3
Primf C" hello m Niaamaleca "
3

imt helld 1t Niaomaload m'" 3


pimtf (heulo \ Ni3amabad m 3
Canage Teum 11 helo m")
printf(t This is

pointf ( This fs form feed Sym bol¥


Soumd 1nJ
Poimtf a 2t is used to emet ade beep

mouoledg is powen
Pitf
pim (" Healt fs wecth \

atch

Outputs
hello
Ni3amabad
helld Ni3amabaa
heu
hllo This is CosTia un
This tsfo feed symbo

a is used to genes ate lbeep ound

Kmouledga is Pouwe 3

headth fs weut 73
Rules Regulafioms wTite a P0gTam

4.Eve C-proTam must Stat uwto


maim
1S a ome the Specias fumcHon
maim)
iS done b
Cmd evy pro83am eLetutiom
maim
3. Fumctiom
a CollecHom of TUles regiadins
Fumciom iS
A fumctiom pesfonmney a specific task
Tm c- Jamguag fUn Ctioms o classifed
in atyp
4. pe-defimed fumctio0m

Builtm ffumcHon ibiou fumtiom


Use-defined fumchoy

4 C-Supposts o Case SemsiHve eautune


i. t allous on dowen(ase chadactey
fo1 biauy umchons amd

5EveH mple Stdememt im C-Jamgua


iS teimímalu d b emitolom)
C-SupPous Ho 32- eH wonel S ThH
allo CalLd a Ese ved wonds
Com stsu cthom emaisw JamguO
f

wo1dS Stoucture pårag3ap w


aS
Comstsuchon o C-omguo- Cp0JTam)

charseF TOkemnS

case FeyoordS
a-3 (ouwes )

A-3 (vppen case) Tdenifers


Vasiabley ImStoucHomns
0-4 (dfits)
datatype
Spera ComstamS pTooom S

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

Vasúable is a m amme Stoes Some dada

depemdm POM datay Pe

Dasatype
defimtd Vasiables
Dattyps au used to
re DfF data which we
The determinsthe
are stoimg he vOuaoleg

Dodar

Prmauj datayp Secomdu dadatyPe


primive cdadatype den?ved dadatyp

NumensC StsuctuTe
UmiomD
ehar
Emum anate.
Jon F stsim
lca dadayee
double
Dataype St3e omveSTo
Specrfaer

chad - bHte 28 t0 12

umsimqed loyte O056


chan
1,d lo7D 21
a byt
32167.1
umSimgedimt a byts| o to 65535

Jomg 4 -21 1U7,483,Lu& To, d ov % ld

ta, u7, u831647

tload -3.4 E -38 to


3u -3&

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

to Specty the vauable a

mtsm 1s used
mumm bn, T+ 6CCupfe
Stomes a whole
ohic
a byy memmd

Jomq Jong is the etemsiom of 1ntegen, i


s to Speurg the aables tohich
aljo used
StoTe whole numbey, vauabley which Story

wnole mumby which 6CCupiy 4 bty

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

dato ype then 1 aCtep posHUe ond


ne gave mumbS
neaahve by default all

numei da typy a Siamed.


Omsigmed 8
to
mumen ic
We Cam pe fin umsi amed
omly pos?Hve
datatyp them hat wil aCcept

Mumb eg
Chagacter cchar) 3

chan is Sed Specfg he d Vaable


ohick Sto a Simgl Chat Cter

Shim
chasac fers s Called ag Shrimg
Shring.
Grsoup of
Stsing 1S mot a datutyee. but to Stove a Sig

we aSL usima chasaltes

fumcHom sed to
printf s Sameared

d's play the teot vaiable value

Displan 09ny tet s

Prinin om +ent3
Synta1 8

grmt("tent ")

ample 3

primtf " hllp"


pimKng tet a oma witw vastalle Value 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

primt 7 d" 3oll mo)


to Vas able
wYite a proqram defime
Valle
OAsS Some value 4 display thevae
majmC

ci ScTC3
int hmo 3

ht no LO1
numm be7
Prit(%d is yous hal fícket

tcht 3

outpute Lo is you hal fHclee numbe

demom &hratn additi om


writ aprogTao
otwo mum bUy.
mmaimc

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

outpuur add ofF a b ís 30D

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

Otpu add of ab 3s 3bD


Sum av3 mayks
wTite a ProqTam to Compu
a Studemt Consídemg 3 Suhfects
0
maimt

mt
elTsCTo3

m2 5
m310
tot= r1+omm+m3
avg +ot 3
%d 3
of he Studemt is
Pntf CThe t0tal magks
tot3

he avg mas ks of the Studemt 1s 7.


Prin

getth3
3

oud put g

The totas maKS of the Studemt Q55

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)

printf (" Ente ous mam e n)


scanfs", &st)3

FrintC ous name is s, s4)


getchC

pul 3 Et Jous mame


Nw aMupaMm a
,

wite a paogramo to accept a mume Gmd

displa that mumbeV.


maim(

closC
erintf ( ent mumbe 1m

Scam f ( ),d" 4n)


is %d " )
PTi (u The mumbes
etch
3

output
Cmtey mumbe?
10
mum bes íS 0)
The
vaues
wwite a proqram to att ept a, b.c

Compute 4 display the additiom of 3 valueg.

maim )

imt a b C3 d3
ClosCo t
printf Emtti a values m")
Scanf ( 7» d", 4a)3
a

print(" Pme b value 1m")

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

ddi tion of abt 1S


3

,
-

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

Stm ple ntest is 20.


fi-5

pToaTam to accept product mame


wte a
@tali Quamtity CompUtL 6 amoumt
pite
amd
8emenate abill.
moim C

Cha Pmame C 1533


int P.9amt
clrscT
Pmupama Hypes MaTket *** n")3
printfC***
pTintf ( Entt pooduct name m"93
Scam+ S PMam e )3

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

Anupama Hpen Market *


**
VaTmi Road N2B * **
pDame
LO DO
Rice
***hamk You Visit agaim

wite a proqTam to Pepot Cord oa Studen

OuP u be

Studentnorme3
fathe mome
Hol Hcicet m0

M
St
SO
1GY FS SecuTed MaX pa.s S
Subject Pas s To1a

maim

chad Smame(203, fnamme 2o3, class oJ3

n RollMO T HE, M, Sc, S0 T0t


+dayspdayss
fload
printf " Apoova school \m")3
primtf " Khallel wad i, v2B An)
pvint " eRo ReSS REPORT 2021-2022 \m")

print C" Ents Studemtmame \m03


SCamU" %S", Sname
psintfL Pntei Fathesmame \D")°
Scamf "%s", Pname )3
prmtf " Ptes cla ssy) 3
Scom ( /6S", g class),
pimtf Pmes Roloo m")
SamL" %d" RollNO)
Primt EmtesT MnkS A)
Scant %a" ST)
Pyimtf( Pntts H Mars m
Scamf ( 7d", & H)3

Printf ente Maiks 1m")3

SCamf (Zd", AE)3


MaTkS m"')
Printf emte M

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=

primtfSubject }t Magks \t Mama ks \t pasSmarks


m')
F Telugu t %d t 00 t 35 m, T)
print
print f" \t %d t loo 35
Hindi m, P)3
\t/d \t joolt 35 m E)
pnintt "Enalih
It 35 n, M)
print ( Maths t \t
d too
Sc)3
Sencelt %d \t lo t
35
poimt
loo t35 m So):
Social lt%d \t
pn+"
totT +H+E+M+SC+So
avg tot|63
Printf Total d \Y> tot);
=
point Average %.2f |m' avg)s
printf The total piesen days ou o(206 )

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

Tmpliá Dcda Comveisiom


Eaplicit Doda Comves STOM

4. Tmplicit Datau Com VerSiom

the data rom ome daatype to


Comeytimg
S?mple
anothe data type
automafi ca bySing Smple

a Tmplici t
assígmmemt opeg ao7 s kmowm

data ConvenSiom.

Autornadic type Comves siom.

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

wTite a progqa to Comvent data fiom

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

Write a pTDTcm to acc ept a cheacter


yalue
amd display t's ASCTL

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

oudpudt Enters a char A

AsCIT Nalue 1s 65

a poga TO accept ASCTL amd


wnite
displa 14's eha1, Cmumber to cha7)

ent3
cho 3
clssCTC)3

Pf" ("Enter a mumbe1 m")3

Pnimtf C The chas CYm°> jD


gtcht
3
Ousputg
Ented a nuoben 65
Tne cha S A
LAibe a earo.m SalL
Erplicit dada Comvesfon3

from dad-a ome type T


dcda
Comvestimg the
its o7 ge
b Specfin
amothe1 daatype enplicl
Comvession.
Enbwn a enpliciF data,
Clata type is

USe defined
Cam Hpe Cast t0 ake he
USed
ponticuaru dadatjpe.

ighe data type


Popicit Lowen dad *Pe

15 wite a PoDITa demnom to ate enpti c?+ da

CowenSiom
maim

a C
float C

point f" £mte a b Vaues m")}


Scamf ), d 7,d "&a , &b)3
C loat) alL
poimt4 io of a,b is /.f \m" c3
Gtch
3
Outpus Emte a b valueS
lo

1S 3.3333
div ofab
s
PTOgamín
Structwse OfC

Comom eMt Sectiom


Limkage Sectiom
Heade iles
Void mair

DeclagaHon Sectiom

ImpwSeion 3

CesS Computafi om Secio


Po
Outpu Section

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)

6upus Emtet ab Values

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

Headen Sles| Limkaoe Sectioms


fumcHom
Tn C- damquaqe eveu4 ibsa
Code ha Stored inomeefle Called
Heades Ale
Whem ue Oe using a oa9tufumtH om
program ham we must Speci
pecij
he
1
Headen file at lm kaqa
s Cores pondimg
SecHom
Librasuy Sumchoms Headeileg

S4an dasd Tnpu Dutpu


Fumchon
pntf C SCamC)
puts C9 3es c #nclude< Stdio.h>
putchag C) getcha) CO7

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

CoS tamC)3 #inctude mat.h


abscC)

DStimg Hamd im9untHom


Strent StCPy tinclu dezstin9 h
St Cat O3 stup)
h"
St lwn Stoev tinctude Stimg
Hand lim fumctiom
chasactes
isdigitt imclud e2etype.h
isalpha )
is dowes C isuppes t3 include "ctype-h"
to lowe 93 toupper j
Allocasíom fumctioM
Memd
+incude <alloc h>
mallocC
Hfmclud eatloc.h

Opeiasa
C Jamgunge SupportS o Vasuous typy

OperadY
1. AithmaiC OpeTatsy

a. Reladionad opeiady
3. dogical open ady

Umay oped cutroy


SASsigmem openadas
6 Btwise openada
4 Anithmaic Opeai3
The Avithmaic opesadõy Asedto do he

mocthmasical Calicuwaioms.

AdditHom
SubstsaHom
nulA plicadiom
DivSioT)
oduo
ov
Co-effiecient)
Divisí = l2 5

Modu0 5 2 Remafn den.

ugima ATithatic oPerdi


wTite proqam
a

Athmai opes adîs rrooam*|


HmcludecStdio.h>
includezonio. h>
omain

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

wTte a pTOaMto usim Relasioma opeiat3y.


8)
Relodfom a openadoy PToqsa m*

Himclude< Stdio h>


imcude <(omi0 h>

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

primtt a thanb %d m (a>b));


Pointf
eati
aqrewey ham equal b
. d \m (a>=5));
m (a!=b))
primt4 a mot+ equats to b d
(a b))
pTimt a equals to b /,dlm

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

Logical opes atd9 a9LR USed Comstuc+ e


Commpoumd Comditiom.

* 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)

Printf Value is ).d


.d 11r 1)
Decsemen+ Value is
poimt (
gtcwt

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

AddHiom aSsiqnment opes adol +


1
a+=10 a at l0

d Sub Sractiom assiaD memt opeTdOL


aa a-10

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

+includec Stdio. h>


Himclude 2lonio. h>
VDid maiml)

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

Bitwise oqtcal AND

OR
Bitwise lvgita
xop excuus
Btoise Jogtta
dogilal NOT Ccomplementdy opeaa
8it wise

Bittwse Leptshif+ 2<


Tndvidual opes iy
ituist Riglw
sift >7
BPtwise Jogicas
demomStrate
wTite
opevadd3
openaJas *|
on Bioise
*Demo a
Hincude <Stdio. h>
Ht imcludec tonío
h>
Cy
Void maim

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

pnintf "d value 7.d \n" dj


PTimt evalue d \m' e);

pnimt f valu e d \n> f1


pvimt C value

ateh
3
acideznat w

0aput Tuth Table


agb Ia
a
Value S
d vaue S I
e vaues 0 1
0
Value iS
Value is --13
O00 o
0 1
PDCesSs

a 30
5-
a a3-o
a Oo001010
a&b
a b

OOO0 000 ab

alb alb +2+R


+ut 2

oO00 O

OO00 |1O0
QAb +
00 O O
00
6
-(m+) -C104 -1
C12t) =-133
(nt1)

Bitwise Shift opepato


opesatoy
4 left shipt opeT aho
& Riakt Chift

Ship+ operao
1 Left Sid e
sid
bits 7owandsS
townd Jeft
moves all the
Specipied noo Hme
fo
to demomSHate ef+shifF+

1*Lef shi4+ opes atiu *J

include <Stdi0 h>>h2


1nclu de c lomio.
void maumc

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

|. Rigkt shift op es asoU


moveS all he bis towandS Right Side

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

Bsanching StatememtComdítiona Statememt


Decfsiom making Stattmemt i-

TO Tum Stei the {lou of COm troi Skpfing


Somne StadememtS and eiecwing anothes
Statements.
. Sinple-iF
felse
3
f-else-1 else . if -laddes
4 Nes4td
5 Suwtcu
3 JoopS Itterave Statements 8
of State ments
>USed eaece a bloc
com diHo
Omce based On the
more tham
Spec?fied.
while Joop
do -ohfle
oop
fo7 J00 p
Joop
Nes ted

Comdiffomal Statememts ramching Statem ents


Decisi om macin q Statememt?

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

S Sim ple i po3am


pooqram to aLcepta gtudemt
wwite a
o a enam 1 marks
| Seturi ed masks
you Qualiffed.
aloove o díspla
Hincude 2 Stdio.h
tinctudez Comio. h>
vOid main

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

timclu dec Stdio.n>


imclu de< lomio h>
void maimC)

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

ou a7e not etgible fo vote


LODite aproq7am o Ccpt a mummbey
+ 1s evem 0 Odd
and detenmined whetheN
timclude cStdio-h>
imclude <comio h>
vDid mo.îmd)

mt
ClTS 3
Point" Pnteoa numbt \m")
S cam " % d", &m)

print Tis a evem num be 1m");


else
iPrint f îs a 6dd numbe 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

printf(" ente a number 1n)


Scanf C'%d", )3
(m =0)
is positive numbe 1m"'j;
ppjntf "It a

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

printf C"a is magimum m")3


3

else f Cla)
pint ("b is maimum m")3

else

piintt t" Both a7e equa "J

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)

-ve numbey \m")


printf T fs a
3
else

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

50 to 5s9 Second clas s


uo to u41 Third Class
beloud 40 Fail

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)

pim tf C"Secomd class "J3

else F (m> u0)

pintf third class "J

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.

9 bu amoum+iS above 5000 & beloo 10,000


the Tate of discoumt is lo/.

fLT bl amount is above O1000 the Tte


of disGoumt is 207.

#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)

díscount is 1o. m")3


printf (" you
d bo10
else
pymtf (" No díscoun m")3

Printf (
printf
printf "
You
You
TOtas
i
discoumt is d
Yoy fimad
%d

bili d
,
V°,

m f)
b;
d)5

pintf Thamk You visit ag0in)


rchu
Dutput8
Hypennas ke ***
Hmupama
**
EmoPOoduC mame

Eme auam Hh

Pmten

* A Pama Hype nayket *

Naini Poad 92B *

PoDdutt Name Guam Hy P7ice


Nested-1-
with im a fCo3) Condifiom wi th im a
f
Comditiom isEmowm
Nes ted if
Flouwchats
Symta
Comd itiom 1)
if
-if Ccondtiom2 ) lond
T
stat
Sta
else 1fLCond else
a-7 Stat 3
Sto 33 Sta y

belse Stat
Sta 53 Stat 2

Stat 6
Sto5
S+at
(Stop
pogan to accept a mum bed Omd
5write a

delesmimd whetbe iF S posiHve Simale dg


o not.
imctude 2 Stdio. h>
4imclud e Comio. h>

void maim (

Cl5SCTC)3

printf"Entey a numbes \m")


Scamf(/, d", 3m)3

iFmo
i(ma10 )

Pointf C is a +ve Simale diit m

else

pimtCT+ is a 4ve but mot simgle diit v)


3
eLse

pintf ("Tt is a not t+ve "3

gtcht
OutputS Emk a mum bed

Tt is tve Simg digf


Emey a mumbe7

T is a +Ve but mot Simgle d?it


Camdidade (udent)
wTite wrtte a progamt aCcept a
pilimS maskS aodve
macs im prilmS enam f
mass, main AaN masE
56 accept m F
albove50 displa You selected o1he post of TAS
not selecked dsplay the eason. 1., disauaified
poilims D mains.
+include < Stdío.h>
#imclude <Comio.h>
vOid maimc)

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)

Selected for the post of TAS Jj


Point You

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

rom the mulHple Statememt Switch Kes


im
Depault pmd break 0SL ewoTd S used
Switch (oncept
Sgmta3

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");

Scanf"hd 7.8", 8a,3L)


printf C'press + to7 add itiom 1m");
printf(" piess fo7 Sulastoaciom \);
printf (pness* fo muli pli cuHom m')?
pyintf press for Moduld ");
pointf tEntes ouo chofce )

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

pDgram to elop skudend helpdetkx


wite a

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

primtf Enteo 3 fo3 M.B.A mfo m")

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

Jotated at Sout block \m)3

6eak
class zoom a7e
Ca se 3 pdint "The MBA

dotaed a Se Central block \n


boeac
d
default ? pr?mf C" you au enered a ivail
opHon pls tsy again \7
echt
3
Dupus
Pflus Cstdim) eomple poooam
#include stdio h>
tfn cudectomio h
void mainty

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

in clu dec stdio h>


Hmcludez comio.h>
void main ()

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

Scamf Cu / d" num)g


num 1S
Squane o he bes
PpintfC The of
d 1n res)3
Tes Sqst (mum 3
of mumbev is
pointf C The Squane Ob
m", 7eS);

erch C

OutPuts Cmte cnumbey


5

The SquaY e oOf he mumbe r s 625

Oot of number fs5


he Squene
goto
a
3t 1s used 4odispl the ouput at
perticulan place he SCT eeTD

dem 0n stIake 3otoy


wite a oTam to
incude 2stdfo. h>
incudec tomío h>
void maint)

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

Tm PDotant as pectS m Joops


doops

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

Dil beeaecuted. StOP


StoP.
False them 8ofD
whem Comdrliom is

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)

Printf (" Ned ATupana 1n" )9

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

oupu emtes value

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

PTimtf (" Pniesm valuem)


Scamf %a",47)3

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)

pinf C Ente nvaue \m")


Seam /.d m)3

im
while ( i> =1)

pmimtf (" 7.d \n", îy;

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

avg float) Sum)n3


prinf avg ofnum bess ís 7f 1m, avg)3

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)

4.Then it checkks the (onditi bn.


a fo 4 will be
5. T Condi tion is rueSep
eLetued goes B
lomhol
TCondiion s false the
6
O the oop.
Flouwcharts
Syntais

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)

Poimt C"entes Value m");


Scanf C
/,d" , 41)3

do
pointf"%d \m", i);

while ( i2 = 100)7

gtchb

Outpus Emt vaue


100

2
5 woite a pro nam to pnt 4to MumbesS

do- while Apop.


|sing
Hinclude 2stdio.h
nelud e Ltomio ho

void maint

nti,n
Clnscs3
Emte m value 1m ")5
pintf
Stan /d", 4n)
1

printf %d \n",i;

while (iL= n)

Oukput Cmle mvalu e

10
numbes
Pbganm dfsplaying1 tom even

using do-while loop.

imeludec Stdi oh
Hin clude < tonio. h
v0id maint
mt 1, m3
clsc (
value \m
printf C emtcr

Scamf "% d"Šn)

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

Printf Pmte m value \m "3


Scamf ( /d &m)

do

Ch 2 1)
pintf d\m", i)3

oh?leiz=D)3

etht3

Outputs Pmters Nalue


(6 wrile PTogam to prit to 1 Símg do-hile
Lwop ?

imclude z Std1o hy
timclude clomio h
VDTd main ()
19mt i,n
ClTSC

p1ntfl" Ene n value 17


Scamf C%d" &m)

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

printf %d \n", ')3


SunSum +1

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

for CiníH Con d3 Imte|Dece)


StadStat 4 CloChant: /iniR
Stad 23
3
(StOP FLomd

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)

foT Lie13 iz=n 1++)

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 Adding he pesent& Poevious mumbey

6OTVte a prog7am pYime 0

un bed uwi be deuided & sedP


wite a poITam poimt sum f digs
t mcludec Stdio h
tfmclude comnio-h
void maim C)

pim tf C"EmFosm numbe7 \m") ;


Scanf " 1, a", Sm)
Sum 0
while tM> 0)

e M/» 10
Sum: SuM +eTm

pntt "The Sum ofd'qits is .d Ym, Sum )


getcht

oP Emtes mUm be?


123
The Sum o digi is is

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

the sum of dgiS 1s 3

Sum 0
while (120 >o)

Tem n7 ld 120 "/.1d 1o)12012


120

SUm- Sum +Tem


Ot0 Sum o)
120ID lo)12-o (12
12

m12
0
Sum
wile 12 >0 )
T

em 12 10 1)20

Sum z Sum7m Sum 2 2

to)12 0
1210 2

Sun 0
while Ci70)

ven 1/%10
1

Sum Sum te)


2 1 3
twnite a pogaam to de mon sat of
Mumbes
imclude c Stdid.h)
fnelu de c conío h>
void mainy

cioSC70
pintf (" enes mumbs \m")
Scan f C d" n)3

while m>d)

ev (7e v) * 10 t7e m

pimtf "The 7eueise bf digitS /d \m "j ev);


getch
3
oulputs Emie mumbe
u5b
The eveise da tis s654
Compilaioms
lo)
nu5 u55
ev 0

ev Tev lo +7em 10) usL5:%


Tev 6

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)

printf "Ende value \m")3


Scamf ("%d &m
fempn
ev= O
ohile (m >0)

ev CTev) 10 +7e)

3
1 em p == 7e v)

poin tf (" is a paindiome mum bez ")

else
no4 pali ncaom mume )
gekcho;

Ouhpur EmHe 7 M numbeY


12
is a palimds 0m Mumbes
progna m to demomSti at fibomacei
wite a
Sersies
ttincludek Stdio. h
Himctu de ccomio. ho
Void maim

nt abi C,

ClSCTC)3
a0
ba

Pintf C" Emter vae \m*);


Scam "/, d ", &m)
pintf ("% d1t % d it', a b) 5

fo C
1 = m- 23 í++)

C a+b3
printf %d \E, C)
a=b
C3

qtchc

OukpuuF Cmtenm value

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

poimt ("Entes numbe m


Scam ("%d", 4n);

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

int D TeM)Sum, temp

pint C entes o mubes \n")9


SCamP L7.a", n)3

Sum b
whiletn 7D)

Sum Sum + (7em Tern * em)

ftemp == Sum)

pintfT+ is a Amstsong mum be7")

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

for ( nit tomd InTaDecTe)

Stat A

S+ot 2
3
3
ollowing oP
wnitewrite a ram to dfsplau

usin9 mested dpop.


b
P
2 3
5 6

13 14 15
12
19 20 2-1 mo of oS 6
16 7 18

Himcludec stdio. h>


imclude 2 Comi0.h>
void maint

imt , C, i J9

pimtf("EmtC3 mo. of

Scamf C"4,d", 2mr);


C1

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

rimtf (" %d\t", 1;

gtcht
(640te a Poranm to displayfotooin Oupu
ouput
2 3
2 3
2 3

2 3 5

Himclude zst dio.h>


+imclude c Comio. h>
vOid maim
imt T, j3
clsCC)G
pintc" Entes no. of TOw S \M")3
Stant ( %d", 27)
foT i=1 iz=m i++

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

printf C" 1n")3

(j-1; j4 =í; J++)


for

print f "It " )

gedcht
d

edample pogTam for avTa


maini
mt i clTSCTC)
10
303
f-100
Pinti l"i value is d \n> i
geche o

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

Ome DimenSioma ATTO 1DA

DOuble pimen Sioma


2DA
TwO Dinem Sioma AsTa
3. MultH Dimen Si onad As

OOne Dimemsiom a ATTa


The one DimemSiomad Aroa elass fied
3 +ypes They

4. Numeic one Dimem Síomas Aso


2, cha ac tci ATT
3 Sting AT C
umes íc Ome Dmensoma ATT

Stoves Colleciom of numbeTS hich


beloma S to Same +pe C homo2emous
DeclaraHon of 4D Aas
SJmtan
Datatyp e a5TOyNAme LSi2e3
etamp)le
imt
ouoove mum 7S 4D mumeníc
Lm Lam Ple
m hat we Can Store upto 10 inge
AT
vally

emo Siaes
NO.DP bytes pe a datay pe
NO.O lemen ts*
lo bytes
Tota meTp Siae s
3S ao ty

ASSnging vau to ATT

w Cam Naues to Arra in 3 uau


4. Dimaroi eim? tallzaion
. Di1ect assignment
3 ASSigning valuts Tum

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

nt 1C3 10, 30,10o

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

Scamf 5 doopPS Com Cepts


by usimna

to accept Values mto Arva3


wnite a pogTam
valuy.
displa that
#inctude <Sdio h
Himclude<tomio h>

Void maimty

nt num CiDoj S2, f3

cost
primtf Emter how mam values you want
to um 1m");
sCam 7»d'» Zs2)
fo (i=o iLS2 i++)

pintf C" En tea , d value m", i+1)


Scamf ,d", 4mum [13)D

pointf ("m The


aoa vaues aTe n);

OT (i0 14S2 i++)

gecht
Outpurs
womt to mum
Emte hoo mam vauesS

e
Emtes SValu
LOO

2nd value
Emte

200
mtes 37d Vau e

Emtey 4th Value


20

The valueg

00
200
wwite a proqsam tv demom Srate chasacte
aYTay

imctude <Stdio h>


H imclude < Comio. h>

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

ppinfC enieo dchao \m", i+1)


fush Stdin);
Scam ZC", ych i1);

printf C The aTnay chanac ens auL \n")


fOT Ci0 12S2 4
prin C7C hti3);

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

fos Li D 14SZ 3 ít+)

printf " nters /a numbei \n", i41)


Scam C" Z a", 2mum [i3)

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

The manimum Valu e


pimtf"
man )3

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

Scanf [" %d", &S2)


pyif(' Entes chas m")
fo7 Ci0 iS2s itt)

pimtf ( Entey %d Chan n", 1t),


flus h Cstdim) ;
Scamf%", &chCi3);

prin" The chaS aTe m")

fov (i0 izS23i++)


primtf 7.C", chC13),

Jach t
Sring ava
Sting S a Collection of c hotacters.

po g7a demostrateStin q 0TTay


wite a

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

nt malC3C3- 2 1o, 20 30,56} ?


Houo Data be Stored m

he wi be StoTed 2D GT O
aTa
mderSubSori pt StaTt faom O

mat CoJ Lo3 o


ma CoJE'S 20

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

Hme b uSimq SCam amd


-to
twite a PTOgTam demomStrat 2D-aT (o

wTte a pmootan acceptdata im matriz

and d íspla that da


maim)

imt mat l5]153,. ,mC 1j 3

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 Ci-0 3 34T j+*)

poimtf" tntes %, o Yow %d Col1N i+,S+1):


Scamf C %d", &mat [iJCIJ) ?

printt ("In he aT7ay Nalues aTe m )3

fo O; imi 1+t)
WI)
mimtf(% dit", matl

ch

Outpul
Eme mo o oS

Emtt no o ols

Emt data into aT7 ay

Emte 4 0 4 Col

5
2 Co
Emtti

2 0 Co (

Ent
5
Enti 2eo

The Oy Jalues

5 36
poissaie

nite a oanam demom strat tams pose o

matnia
ColummS
pDse cams
T9amspose
TamS eveise i.e, 70ws d

Columms o DOLOS

maimC)

nt mat Cs3 [53, ,mc, i,jS


clnscoO
pyinf C" Cmle moof Tbws m")3
Scam C
%d", ns)
pimi4 ene no.of Cols ym")

Scam " d" &m) 3

primtf ^ Cmaci data no mat \m°);

12n7 i++)
fonio,

fon (j=0 J2mc3 j+t)

primtfC'emte %d yo d colm, i+)j+1) ,


Scan f( %d', amat C1] CiJ);

pintf (" m The Avi ay before values aTe

f67 (1-o 1emT; 1++)


for (=3 34me jtt)
inf( %d t", mat Ci3L33

Pimi C
n The ma values afted 47anspose are \n

Printf Cyn")3

3chd)
outpug
Emte n0-0f TOwS

emt no.f Col S

fmte data m+O mat

25
2 Co

buD 1Co
Emted
Emteo 20uD 2C61

The aTma befone auts ane


5 G

36
The at values afte t7anspoSe

a5

+8 wite a Prro aTaM demom Stz at add+om of

maimc)

int mat 4 C53 [5), mat2l5JL5], Sum 53i53,ij, S2

print (" Intei he Siae o mat and mat 2")


SCamf (" d", ys2)3

Tint " Entes valuts nto mat -4 \m")3


fon Ci0 iS2 +t)

foT 0 j4S2 33+t

print"EnkaJ% d Tow /d Col


n" i+1,jt D
Scant %d'& mat 1 CiJ

3
* ew

Prmf Pmtc Vaues imto ma 2 ")

fors i0; i2S2 i++)

for(0 3 j4Sz S+ +)

primtf emtes d ow %d col m", i+)) j+))

Scamf ( ,d", 4 mat aLi3LIJ)


3
3

Pintf C" In ma 4 Valueg ane m")3

for (1o i2ST3 1+t)

pointf C" \m")3

printf (" %d lt", mat4 C3 LIJ:

inf C /n mar 2 Nalues are \m");


fo i03 14S2 i+t)

prin \n")3

print dt mat 2 13 LI) p

3
mat 4am d mat 2 Values
PTintfC m Sum of
ase ln" )

fo Cfo3 12S2 3 it*)

pvrintf \m") 3

fo (-o3 4S7 ++
SumL13 L mat LJTIJ1L
+ mat [ij LJ3

primt (" Jd\t ", Sumti3 CIJ)

eteht
3
Outpur
#mks o D S2e o mat 1 amd mat 2

EHes data ntd mat 1

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

mat 4 vaiues aYe

a5

ma 2 Valuly ae

20

Su of amd ma 2

3D
write aprDgTaM to dumom StTate muJiplicadrom
o maia
maimC)

mt modil53L5), mad2 Cs3l53, mu [53Ls3ij. t.S2


CioscoC)3
3
of mat 4 mat 2 1
printf C Emes Si2e
ScamtC .d", s2)3
printf L"Emtc VaueS mtD ma 1

fo Cio 1Sz 3 itt

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

foo (1o 1S23 1++)

fo -o 3
Jsz jtt)

pintf Cemte d 0w /d Col 1m") 1++1)

Scamf () d", mat2 1J WI)S


3
4 values ase y"
printf C mmad
foT(i=0 Sz i+t

primtp Cm")3
J++)
fo (=03 J2Sz 3

prigtf (%\t" mat 1 LiJL3

3
pintrC n Ma 2 values ae m")3

fo7 Ci-D 9 12Sz i+t)

pain*P C"ded \a", TBALJUJ 3

printf C"m")
fon (i05 34s2 3i+)

pinf 7.d1t°" mat CI LIJ)

prtf (C" mumu b mat 1 mat. Value aze 1

fo(1s0 14Sz ++)


poiml m");
fon C0 4S73 j++
fo CE=o KSz 3 ++)

mu Ci3LIJ= mu L1JLI3+ (mad 1 (iEJ


mt 2 IÜI);
mtf (" /d 1t, mw Ci3Li3)

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

(ose, tam C H melude <math. h


Sin),
alLsC ogt, Sant)

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

OTte a program to demomstsati matamadî cal


funetioms
inctudez Stdio. h
4 imclude cComí6- h
4inclu de zmath. ho
d main t)

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

The Sim Vale s &uIUj

demom Stsa Stofn


wite a phogam 0
hamdlin 1 unetio.
in clude 4 Stdfo h>

t1ncude c Comio h>


Hnclude cSHima. h
V0íd maín()

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

Telam gama State


uwnite a progsam demom StTeti characheYS
hamdlim4 dumciom.

wTite
oa to aCcept gharactes

E1m Small case Comvert it intD upper (ase.


Sm?lady 1S Ppes CaseComvert 7
into Smalles tose.
timcludeLstdio h
Himclude <comío.h>
+imelude < ctype.h>
VOid maimC

chars cha, ch2

pTintf ( Emt a chas m);

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

printf" Itis a Specfa Symbo1 m")

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

Code of the funcHom

Bonifi*s 0f USes defined uncions 3-


1. Reusability
2.Saves the Hme
3 imease he pocess ing Speed

4. qeduce tne roIamim9 (ode.


t demom STatu a use7
wite a Plogram
definedfumcti
maim t)

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

ointf( my name is k.Anîyudh m")


pr intf C Dplom 2nd yeas m")3
p7imtf Baamc: Cse \n")
prmtf (" VReC m")3
printf C 2B ");
3
Creatu a headerfile md
4) urte a pogr to
accesS thatile in amothe Poam
DpemOpem MOtepaad

uwdite funcHom Co de tke

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

CCcecsím aloove heades file im amothe


ProqTam

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

TOm fumcHom definatiom to un tHom Cau

tte a PTOTam to demomS tsakiTun


'eywo d.

es
cloSc)3 Sumcion Call
res Squase)
printf he Square o he nD ish d \n Tes);
qercht)

Squase C)

imtf C" £ntts a mumbn \m")


Scanf (4a", 2a)
SumcHon

Teuin deffnatio

n s oimo quc e
Dutput
CHe a mumbe

Vhe Squame o he mo1S

Cau by vaue pssína Cau mesmts


pass vae
b umctfom with Ogum ems

passimg the data functiom Call op


fum chom depimaiom is efens to Call y Value

Symta
deusntype Fummame (aTgum emtS)

Code ofthe fumCi om


3

fumcti om Ca
umnamme CagqumenS)
wte a PTO 3am to demmm sthatt fum c4fom
with arqum emts

Wrt a proraM demom ss ati all b Value.

maim C)

clisCT)3
Pintf C" Emtera bvaluuts m)j
Scamt" d a" a, b);
Sun Ca b)3

getcht

Sum imt 7, int )

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-

The fumchion with potoypeSpecPres what a


fumctio eceivS what a umciom Tetuyms

Symtaa t defime PTOtoPe

7etunmtype fumam edatatype dadatyPe)

Eample g

dfv imt int)


loat
a fumction ?t
Jn above ezample divS
etugmS A loat value
accept s amtegerS
demomsthatu fumctiom oith
wiite PoTam
p3Otoyp.
h>
timc lude<stdio.
Conio. h>
imclu de <
void ma?nl)

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

Callimg a funciom ?+self s Called Recussfom

maimC)

clsSCC
PimtfCwelcome 1m")
maim C

1tcht
3 tse
maimC s callinq itsep.
above enample,

a PoogTam to denom Strato TeCuT Sive


wite
umcHom).

Loaite a am to find Out facto7 ial oo


Tecu SSi ve fumcion
givem numbes b usin
Himclude<stdio. h>
Comio h>
+ imclu de L
Void main (

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)

Tes n* faCt (m-})

7tusnm es
3
Outputs
Stuctuses
Simila fype of date
T is a Colleciom of the

im Single va iable Cale d a


which Stores
STrutuTe
Comcept we hawe to
use STuctuse
To
kmDLD a thin}
4 Suctuve tenplatt
a Stucture obiect

Stuctuse emplates- 07 Slw


S blue print
StructuTe tem plate
Com Sist Of dfferenmt types data
ypes of dataa
templdu it
OCCupg amy mema.
but
bu
doesnt
doesm t
defime ShuCtuye templatg-
fEmplati
Symta to
StTuct StructMame

Data tyPe Va7-MAMc

Datatype VaT-Mame

Data tyPe VaT- NAMe


Etample s
Struct emP

int empno3
emameL203
Cha
loat Sal
3
Struttuse oects
S a mStamts of
ofF
Ssuc tuse object
Stouctue +emplau

to deime StuCture Okfects3


Symtu
Suctugename obj4 obj 2, oi33
StruCt

enanples
Shuc+

templat

Secom dau datayPe.


wTite proramto denom Str o StuctuTe

Shuct SsHu
cha mame C20J
jmt Tollmo
float fee

maim

Suct Stu SA, S2, S3 hahu", to 3, l000 5o


St CP CS2.mame, Sumil")

S2, Tollno= lo29


S2. fee = OO0. u09
prmntf(Emtes S1 data m")3
\n)P3
printf Entes naTme

Scanf C" S °> S $4. mame )g

piintf (" Ente7 7011 no m")3

Scam f ( "2d S1.oilmo)

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)

SB. mame S3. Tol\mo, S3 Fee g

Outpuur Bntey SA data

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

StructuTe, t also Std7es


Umiom s ao Jte
of data, the
Collectjons o d?ssimila type
diffevence b Uniom & StutuTe sits
ta Sturag
douta
data in a Sequeni al o7cer
Stores
Structuse OCcurau
while aCcessina me we Cam

umfom StoTe2s dadra not


dota, wheie as
while access TM9
Sequemtial 0Tder.
occu a data. Due
Rome we Cam
Cam 9
we hae
naie to pe pare Tathe
+0 hiS Teaso

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)

poimtf C" Entex %d emp data \n"3)

(entCemo I)
printf
Scam C . d" 4 eci3eno)
primt Ente name n")

Scamf C%s",etIJ.name)

pintf The emp detarls ase m")


m")

print (empnD It emáme 1m")

fonCi-1 Sz 1+t

printf %d 1t z S \m) etJ. eno eci.name)

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

addsesS Vou oble Value


a 2 0D

a 2D
1P 20

a 0
prog1om demomstno poimte7s.
write a

You might also like