0 ratings 0% found this document useful (0 votes) 2K views 38 pages Programming in C - CS3251 - HandWritten Notes - Un - 250316 - 200237
The document provides an overview of the basics of C programming, including programming paradigms, data types, constants, and the structure of C programs. It discusses object-oriented programming concepts and the importance of understanding programming languages for problem-solving. Additionally, it covers the compilation process and the significance of documentation in programming.
AI-enhanced title and description
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here .
Available Formats
Download as PDF or read online on Scribd
Go to previous items Go to next items
Save Programming in C - CS3251 - HandWritten Notes - Un... For Later Suz t
'Ubject Code/Title: CS 3251- Programming in C Unit Basics oF c PRoGeAMmmING
Basics of C Programming
Tatirdluction to Programming Panackiqnes “
of 6 Language - Stiucture of © progcam— proguemmen «
fata types Contant Emumnatdon constants — Reywoorsis =
OPeatmre: Prsclence anol Axsod ant vity — Expacsniona Teput/
PUpuL utatement , Aasfonment gtaterunt — Pecidon Maring
Statements - Quotich Statement — Aooping gtatemants — Preproces
AtAectves —“Comptlation Proce « !
__ pppltcatZons
[Tr Bicctusction to Pargtonnciog a i
Progiamering Paraditgrn wage to how a pacgearn te
erttten Bn dadex to wolve o prebluim- Te Ba tang ko think
about Pregame and proguamming
Progam ming ean be classified Late three Cabegor
* Unibuclined Progrornm
¥ SBuctund ee is?
Ltd only umn Pangea:
i a generally rerctctedl gor
Umatl appticattont, but & the applicatfon
je thin te poter eal diyyvoultine th Erm &
clastty Of the code ) medi frabtity j,and case g une
e fe
on , & program 2 backer
dewn into umatl tndependsnE bare that are umatl enovg!
bbe tenderttood easily , without having bo Uncuastard the
J trhels program at one - de Can ba Pergormad Into Keo ways
Romans
EMENT,
PERCE ANDSubject Code/Title: Cs 3251- Programming in C Unit: pasice DFC Prog RAMMING
Objet Oatiented
Te a type OF Progndmming sf which Prgproummnans
olayine not onty the clara lyfe apa data dbouctune , but
alio the types ef operations that Gan be apptiict Lo the
data tbsurceure .
One Ge Us Psenci pie advantages A obyect Ohanted |
Progeararnicg Eechniquet over procadural Prognammea:
kechniques “a bhak tug enable prograromens to Ora
Met that do hot niet Eo be
7 Changed ustan a neuokiype.
object & addeol.
The basic concept of OOP axe as follolus
* Objecta
~ classes .
*# Bata Absbract¥ond @ncaptulation
* dnherttance
+ Poty morphtem
# Danam& Bends
selisege Posing
gate
DEPARTMENT oF
SEE CERNE ANS Somaniries,CS3281/ PROGRAMMING INC UNDE:
Apr {roationa — of ¢ Prog rarity
‘ (
x Opercitt Systema
4 Empectebecl ysteru
y Gur
y New Pacgrarembng pPlatyonms
« Google
x Moxtila Hrefor and thenderbtred
x Compile x Peasign
x Gomiy and Antmatcon
yteona: -
x The feast Operating ystem be be che velopert Ustiy av
Kegh ost Progamming language wat ONL, vohteh Lone claategnacl
bee peagaerantag Language:
& Miterosofté cofrelouas cind veulous pndtuotd eepprecetitons
Me ertpted Bn c.
Embedded Systeme’
] x Thc pangrarersig Manguage fs contidiaacd an
optimum choles cohen Te comer to Avspetrg appear tha na arcl
datvers qy ermbeddad aie as th alec aly walatect Eo
Machine hardivere
Gur
| N4UT stands for Gaapheal urea Intoyaca. Adobe.
Photoshop, One qy Kha most Peptenii und phete edfterg voor
created wsith Hea hulp gy C+
New Paogsernnntng plabjowms :
°,
oA Programme
aadttion t be concept Q O4}
dang 2 ie eauatlig Lt tha Geaknes
ect -ottented programming
we én «
put, voxtout ether Programming donguage see metab a
' nok
/ damrattco, was waitlen tn ‘cl
matt
gente cases,CS3251 / PROGRAMMING IN C
xX TE fadluater ta faster computatdn of paogtoms.
Googie:
XGoo gle Fle giysters and Goog Chiomium barocuser
Were cvsteped by wang cle+t. ;
K TRE Google oper Source cormmau
Nuenber Gy panfects being hardled “hg elett
% Moxilla fastox and Thurcerbid were open Sourcr
client pacgec hey ware wattten ch elett:
Complex _pesign | c langenye tank
y Ohe of He mote popular uses @ he
hos a soy
[the Cualion of Compilers: ——
y camptlent for geverat ober prograrnmig Angigs
were dastgned ub ousodation q c wth soio uel
Bq Te enter be be comprehensible by the mci
Example
clang é, MINGM ancl App c
| ant _Prtmation'-
@ prograrnmeny danguage bh lative fasrern Hare
Tawa ot pyttony ou RE ts compiler berecl, CE Ads vevoral
plicalons th the qerning Settor.
Example:
Tre- Tac-Te
Th Dino game
Snare game -
Be Oren OF a anriesee oe
Subj 5 mr,
Subject Codesitte: ¢$ 3251- Programming in C Unit:Basies OF € PRogRAMMnG
TrbroctutHen fo at-
davelope
¥C we gored purpose neghbauel Language
by dennis Pttcht. a ATHT? Bell daborator ls gn lata.
ha Widelte Level e
#C language at pry auloaation |
ang oULLouos, dynamite num “4
* Teh highly portable
Douwmuntation Sectior
Deginition Section
Global peclatatfon gectton
maine) function gectton
% Beclarabion Port
Exeurctable part
Subprogram Section — UAte-dafhal
t
functions
Beoly @ Ha Uubprcgram.
The documentation Seetlon comb @ a ek q Commant
the name qy be Ard other olebaile +
Wine EB a non- executable utatemant The comment
lore placed betroeor Jy and #/
|Pupsocaxscor Sectfon ‘
Paproceuor Lectforn whlch direct the compiler te Unk
funcitons torn Eh uipstem Se
(e-9) tnelucde Lsedin YSSubject Code/Title: cs 3251- Programming in C Unit: Basics OF © PREGREMMING
castorate gectvon' =
& There tome Vaxtablu rat axe wed th morethan |
one functon. Sach Vaxtabla ane called gtobat vortablir ancl
Jar cleclarsd kn tM gtokal dactaratéon gettZon
TEU detland putitde @ al du functlons:
Presa Program usdtlen 6) ¢ language must contaty
ftons ThE weetlon container two pant,
& Declaration Port
¥ Elect able Part
Peclonntion Pat: -
Pe Atctore alt the vortabler ued Ly ba Otaciitable
Part -
Suerrkable Part -
ThE Pert contart the Aeatements fotloustng tu.
atton @ Oe Vastable. Heo the egie a Ene paograr
Gan be Empturnented «
paorids tnttauctfont to the
COMPUEC to patio a Hpectfic touk.
These tur pate mint Appear. bekigesn Ena apsnins
lard tha. alaatng antes
Subprogaamn fen i=
Fe containk alt tha ter oigined fuuncktons thak are
Nositact a) pe main fanckfon . Uséx da fred funcetons Are.
3 ty placed Immedtatly ayer the main funceton ,
neat Bag reap paca th, ny iUnit: BRSIES OF PROG RAMMINR
Subject Code/Title: cs 3251- Programming in C
is Sum g doo number * TL specumentation section !
JH Enclucte ~¢.cbdtfo-h —>Paspaccannor gectton
arouging A G----------—-4 poeyinitton ¢
Voxfable ,
Bon cetttoo
ome Eprom nese tS I oe 4 —>Gleral
the adel Cnt), cleclounc.
oo => mating) Function
mE by TO > = = = ~ 4 ~pprectanation part
PAINES (“enter the value q b);
Scant (“/", kb),
= adel (b); b> Brecutedste part
PAainkf (Sear =-frol ye)
2
add (int b)
es 5
Atk,
futon Cod;
Darery pes
Pakatype ie Eh type oy He daka, trot ar gong to
acess hthin te progam \c! suppor dierent data,
types » each abatspe ia have prsclag crag memory
pArquiaerant and ul @ weprAmentatfon-
abepa
pa or furcamentat olatatyper -
HiME float x double *ChAR
beger (lnk) .-
*Enbegens Or Ha numbers ustth the supportedl ange.
beget octupy one user af storage, and stn the voord
pt | machines Vary froro ib ot 82 bit
* NM Wwe use (b bit werk slength ) che tinge Gan be.
Jrtmitecl upto -saqee bo warey
tnt ay
Float (Sloae):-
potne number are lord uh 3a bik witty,
+ Deh Urech to tose nuarte values |
Dousla (double ):- .
Dour doralupe aumber. wer ba bite gvng a
| Udtgia , these ore knovon ar double Paccte
(char): -
A single character can be CayeRecl Os Char doreatty Pa}
Chonattere, Ore Atored un @ bit
e-q) char a;
Type Quatipien :—
H we usa tool wort dlength, tine g clara tyre
Jac. Wimibed bo the upeckyic mange: Tneickta to provicla to
J contact oven Che Aonge & Mumbo and storage pace &
| ete alabatype woe Ute befre aatitans The Ore,' A
Subject Code/Title: Cs 3251- Programming in C Unit: BASICS OF C PRoL pe raming
wre: fon q org ard unatgned integer peumii
Us EO Patreate tne @ volues.
Y, had Rekatypas :-
User doginad Pakaty pe U Ud bo neato new dobre
bynes, Eyre cuctoration’ atlows Usebs to dite an
Toantt fier that usculel Uepartent ait. SRFiing olakaky Pee
Syntarnic
pe. pe ftclanteygt
Wha egre eget to an eich ere dataky pe:
Ponti fier Aeger bo Che nevoname green eo
Aotatype
leqds Cypedtay tnt mai 5 *
Mean a,b:
4
Brother UWr2e8-cligined dletatape Lt enumeso tect sakes
Synbaxt—
[exer went Goats vata win ATG
wT folintefig th ao Ure dag ined sec
(Po Which con be used Eo ductors Variables ok cor
have one @ the valuat enclocedt wotthin the baacesr, Enown
O4 entem®atton conttants .
THLE compiler Ceca aL. Autgns Rntegor igite
beginning tolth 0 be all the enumeration constonB
SED um day Prronclay , Tus, wed Y
enum color J buw=5, black, qruesny Jatlous Y
veal per
per” that are darted fiom furtanentad aaa
One cold dnived datatypes » Berived datatype add !
ome functionality to the baste ata pes
ENT, OF nani
ERA AND HUMANITIESSubject Code/Title: cs 3251- Programming in C Unit: Basie of C PROGPHrMING
& frsscny Teh a collection ey vartablus Y samttuype
# A pointer is a wpectal Variable thar 1, y
adosit % anotur vartable-+
# A Stuur Gs bo muttipG Value g rome OL
diyerent pes undden o irate nome The eriting
Abaucture Variable th utound cin” repre
# A Unflon B& alo Uamearz Ltautture , but
2 re
Unfon variables as Ubred wn a Commo
pe te used bo wepaent an empty o%
eB ted ato Getuan bape uf a gunceton
C- Token,
The umaitest Endividuel uth fh ao geome
Jcoutecl e@-Tokunt - Pra
Taantitier ore nome agtven to Various Program |
tenant, auch at Vasfabla, functions ant array etc. |
Pusten
& Toent eer const Cakter anol degity. cn
# the fo4k character mut begin wi char or 4
% Both uppercase ancl Lowercore are PemfttectSubject CoderTitle: CS 3251-Programming in C Unit I: Basics of C Programming Ss
Constank otyers te fixeol yates thab cle nob charge
dasteg the eucutfon gq a progam.
constant
Figen. Peat
S SS ey
roger Coratane '- :
& An Inveger @onutant gormed with He requins GF
Agi. ThAL ae Shaper cy Integer constant rarely olecimak
finkeger 5 ockat. Enteger ard Mxadectrnaf Enteger
% Bedmal tntegem cout ga uek q atzgits ,0 Brough 4
ego 123, —4ag
%& Octal inkeqon consist a any combetnation &% digits pom
the wet 0 through + with, a leacling °
Ceqry eae os 4.
& Henacre?mal tikes com | A chee g aigitx
A Ehough Fo with a
SARTO RomaniaSubject Code/Title: CS 3251-Programming in C Unit I: Basics of C Programming
on ankegor Consbank -
¥ TE mut pave atlas Ore cltgte «
® Dectmal pofht K not attowed .
X de can be elthwr positive o% Negative «
* No spectat Charackere be blantapaus one allourd -
A real constant th mockup qa uequenta ay numeric
digits with prauente a a declmak point
|| Fractional form
A Asal constant must have one ligt:
JE can be etter posi#ve of negative
No commas oA blank spaces ane atloweot
(e-g)y 1-283, -b4e 5 -Abes
Exponantiak fora :-
D Aeal number ols Be. exprenad th
exponentftal cnr) Stentt ec notatton +
mantissa € €xponsnt
Moanlssa eSther a woot roeenbian:,
Teale 2
‘LEI = bab (hott zontal)
‘\wl - Veaercottab
‘Not - Nutt
S\\' — batteetorh
Vosrrtable,
A vartabu A an idan fir ttab te uted bo apresent
tome pect feck
variable
XA Vottable name can be
Olphabeta , obfgitt ot tncirrcore .
C cupporti forma. spectak backs
onstant thot axe used fn output Seuncetons-
lagh chasacber
An ecope
aUnibatrzing vatoble
Vorlable = constant .
cor)
waratdpe. VoAname = cork
ceay
q azo
WE x s100
chance ='o!
combinak®a gq |-g
+ The fist Charatket muiut be an alphabet GL an
Unolortcore +
yx Neo commos
4 No Spectra ymbol axe allowed
oR blankspacst are aulowedSubject Code/Title: CS 3251-Programming in C Unit I: Basies of C Programming
Qherators
fn Operator & @ gyrnbeh tak vepedtpis an operation
bo be peryormed on tu operands The data thems thot
Operatore act Upon ax catled Operards.
Binary Opesattt:—
Opesatoss vuoquire Soo operands Catlad Binary Operate
oor Operators ! -
Operator actr upon “Y one operand uray
Operator .
(eG) ath 4 soperator a, b-y operends.
Operator operates on bhae operands (2 1) t
pe OF ol— |
F Astthmeb’e Operators
* Palatforal operators
* hepteal — opaatos
¥ Aastgnment- Operators
# Snctement and decaement Operators
¥ ConcletPonal operators.
#% Bilwoe operators
! * Speeal operators
Ascthrnabec eg |
C atlowe ur to Gcisaiyottl baste arithmetic operations |Unit
Subject Code/Title: CS 3251-Programming in C
Example :-
Hereluolt 2 stelto-h>
Void maint)
the q=5, b= Ry
Paint # (“suum = fd", ab),
Paunt# (“agg = fd" ,a-b);
Pamneg Cmul thd", Xb).
ee (“atv =+hd", a/b),
Aen f (« 2
(* modat v= wed", afb);
3
Rutattonad operator: -
Pilational operator ane iol Es
I: Basics of C Programming r
Output!
gum= +
bet = 3B
bul =10
pPwea
Modelivs |
Operanclt . Operands
compare two OL mote
be Vasfabte » Constants ot
Sxpaese&ona + The wWerule oy Walattonag
expasreEon bs either
Che CL Zar0.
[operator |ueantng—y]
Meontn!
= Buses
> ea trone
& guaaier Ure
[A greater Hon|
equal bol
He equat to
BL not equal to
ONES! o
M(s<) | 1
>a) Ae
, Deka °
Pathteh (Mp yn ‘
3 nes (My, Card);
gxomple }-
#eenclude £8td th .h>
Pree é (Na yay oy,
Pachet (1 .
cals 2 ‘
eb i Ied" acsb),
able +! , aesb:]
Atincluxcle ¢ StelT0-h>
Vote maka¢)
the A=4, bon, C255
Pathe$ pel", (aradee Co)
Prahet (%y.ct,“Cas2}} GO);
ou Epa i>
se De SovancsSubject Code/Title: CS 3251-Programming in C Unit I: Basics of C Programming
Assigoreas _Opena tos
Ra. a Operatovy are uatd to astign @ Valu
Pian exprusion Of a Value Q a Varttable to gnothér Vortatle-|
Syntarx:-
Vox = ey
(#) compound Quatgnment :—
Apvtt from axsignment operator, C prortolis
Compound Gusta nment Operatoyws to asstgin & valut to o
Nosfable Th iden to autan a newvolus to 2 varfable ater
Pes,
Enompte .—
Heneluds etd tosh >
votd rating >
Panes (Yat b) 5
OW) Neted o¢ Muttt ple A2%anmenk «
He can auitgn a tng
Naltby ple Vasefattes .
Syntam.—
vant
value Of On experton bo
@go
a A=bsex10,
Qumunt ord pe meumnent Operators (unary opera 2)
The treaument Opeaceet tt addt ore tothe vartable
ard ~- OPesaroy (dacrerrunt) Suberacl one Jrom the
Vortablet) po
[S++ Ipoce Jnesamant
A Pac Precnemen
suet veesariansSubject Code/Title: CS 3251-Programming in C Unit I: Basies of C Programming
HF tnclucke 28d to -h>
Void matnce)
bee ass,
Patht + (“ast = -d",a+4);
Patne# raat", +ta)s
Pune £("q_ - Fed" ,0-5
Punt ("--a = td", --0);
Cond? tonat Opmator iti ey ehacks the conitton and
Cx be UtaLement clepancling on tha aordltifon .
0 Exampie:—
dPrctade 2¢ed io. h>
veld magne) .
Operator acti ar a tne ass, b23, bg
Pernany operator , fe Yast evatuateal O'gearb2a- bs
2
a "Bia id” bia): |
tht condition 4 gE U baie Chan exp! ne med ( Bg rd", Qs
24 Gh condition & fale] Oeput:-
then expat eve ated: Bla's
Bitustre Operators
Breast 2 Link s 2 the data a
Bite Operations are used bo ment puta
Bit level. te operates on Tobegens ony
: Example .-
HON 4Stclio.h>
Veid matin)
* re RH yeBs
Putt (“x2y 4g!)
Pane t ore
Pathe $ C8 xay
Patnet (:
tteol
Wed, wayyy
g
WSd 94" e205}
Output '- hg oe
yoo 24g
AMasis neva lh
pases ofSubject Code/Title: CS 3251-Programming in C Unit [: Basics of C Programming
Special operator :-
age Auppectr some wpectal operator -
OPerctos Tembea Uelaction operator
comma Operator *
y~P Wadbo eccers Clomant]
Naot [Mx Qy opercttors om a a taceune
Rade | pointer operators Comma, Opaoator:
cart -> | mempes uctece2on
The cormma openatos
Opearatos
bo reparate bre utatemant eke
Auth ay Vaaiaples
Six Of) operates 1—
yp conkeant o&
Kp eke.,
The tenet) & a Operator yihak wobuant bea bergth,
un bys @ che apecPHted vantable .
Pointer, Operator. —
mL specter tne addrers ay the Vartoble
Ayre upedtas the volus y te Vastable -
Operator Prreedener ard Aasociabivity of
Operator.
Precedence 2 tread to detovning the oidua én uskith
Astthrutre Opamrator prsrcedence'
The OsPthmete Operators Gre erntuated from Wye bs
Jotahe using tte PArscadante & Operators , Loken be. exp &
borttten USthouk Fhe Posamebers,
The artthmuance Operator PArcedenta.
Parscechan 2. Operators
Wah
dour
Pir orrartsenr orSubject Code/Title: CS 3251-Programming in © Unit 1: Basics of C Programming
Enarmple '- -
x- Yat 243 —| g =
32 -9/ataika-|
Wd LJ
o @
23)
LDnput/output Skaternente
The Unput Jourput Functions pounte Gre brandon &
Trjprmatton vetwean tha Borpeien, tink Ente iscunedatzal Prputl
Output dateet - Jn c thput/outpue Suretons Aas clovsh fed.
nto tuo types:
OFormatted Irput/output utatemunt
® Unformatted Input] outpul utatemente
Unformatted Formatted
[Input /outpuk Sime HSrput | output edb
Hapa outpak Input outpal
qeecod | Pubecy Scan} cd 2
Patntto)
qetchas ¢) | Pukchanc) Fsconycs |towne se)
eto) Purse)
eb chee) ad
gcterc)
!
La
PEENCE ANU HUMANITIESSubject Code/Title: CS 32S1-Programming in C Unit [: Bastes of C Programming
A chaaatker yrem the istardand vinpuk tint ard. asad eteg
Te ts Me etandarcl outpue unit.
GeEABRO
Reading a ttre Aharact&® Can ne done py uslng tho
Munction deechan. Yt Slaads a kth character drorm a
bStandard Urpuk olan Cragteand) bt the User prow the
Jeneer kay.
“Y Sgnean:~
Voaname = getranw
Gere
Thue pecker Function reads & an ror ottta olaka
duo the sbandand Input ante
Aigner
Voanama = getcnal)
When Ute utatement “8 executed Ue enkered Chanatter
) uot hou uaa ag fer
Bptcno
The geteh flureaton stsads a slegte: character loka. rem
Jee rtandard ding uni.
p Paeehank Cy
| Binge chanacte® Con be Aiplayed wile the Wibrany.
furetion purchar -
RSL?
putchor (varnome)
The gee funckfon cccapt EAL nome Gy Bee abbng ae
Yosarsker, Hil a nevoline character Te aneountersa .
Syntax :- . . .
geetser); Bem ba aang Vvarfable .
eeme ee cerantient oF
eee CEN ANG SimaniesSubject Code/Title: CS 3251-Programming in C Unit I: Basics of C Programming 9
Puts-
The put function Ls ted to ALaplogy tre ait bo ro
Mandard ouljut davite.
IN bQK T=
Pab(st) ;
“kample:—
AFincluctle 4ctdio. h>
oukpue :
Shelude SrARh. Bier
to Anan
char utx[aed; Fasgemr Paes
PLE (Enter the name"); Mune
FF (ser),
Pas ("p tn Te C4
g 2
puta (sts); ud
Berns
Foumatted input S output function
Scant) )
de ured bo vuaol formatted data from the Keyboard. .
The can function Lara o Le ubiom drome keyboorl.
pexrackx ard formate data rom tha team actording to a formal
ented bing and Hun our ie 3 otal
masala oa data in spec Program
Suntan:
Scan Coniealetig Forgidosga we ang)
ohare Control utiing conttall Ue Required formaltirg
pet feat
dnformation- This beath with a pestent astan(-#
Lttawea "9 aed
bE a COnvestton Characktr +
OG!) CG. oagn ane argue thak dspaciant Use
Pddrere @ Individual trpuk data tent.
feos Single characte Joke > Short Integer
Ted > data WEG f0> Sera integer
are VS > stsiin
hey fob stg -plteaiog polo vale 7 Seng
DEPARTMENT OF
Sar SENEEINE RinsanvesSubject Code/Tithe: CS 3281-Programming in C Unit hr Basies of C Programming
Patt #0)
Te Ts Ured to Ataptasy Injormatton Wwoquitied by tho W109 cred.
Mao paints the valus. cy Lhe Vastables -
Syntax
f (esnlsotet ateg", argi, ange, Bar),
d g d J
Pinclucle < sta to.h> CULE pA =
PR Achucdt eonty >
Ener nares sole O04,
sid mane)
Namo . kurnad
Petine » jaa
avg «Boe
tne uetino
Float avg
chag rat C20];
Parts (enter nana, acttne, avg D;
SOR CS Yoel 7g
7 Ancune, Rarvtlno » Lavg)*
Path ("Narne
‘73
= T*8\q0 Poltho —-/.d\n vq af. F\o', Cara ollno,
og;
Control btalenunt,
has LomekPnd G Vlaterenk that pesuriik the exsculton
ving wtatement cla beck gy statement, In uoma
fordttenal exestfont ont
HoOep a katernant fy webecreol
Ups thE knovon ax selection.
fribaucetona be executed Cepeatertly . |
frat conclttion har been abt tad - ThE EL enous
Of Hite Operations
Con be coted out witha He
Vartour eontiol Ukalementk. io
% ConcliionaL ustats ment
* Uncordittonal ipatementz
sae Dae ocparment oF
Hee seRNC NG So maninesSubject Code/Title: CS 3251- Programming in C Unit: ®
an
wetecton 64 condtitfonall baanehing ) He program.
Conbxet hk taanijenred fom ont petht ty ancthe baud o
Ut outcome g a uatan condition.
ple — Yo Seatemant’ I
K The %f geatement & the utmpliat form @ selection
Statement j Hat & faquantly usel Sy dechion maby.
'
Sonn * The TF condition & erotuared
PLtenattton) fist 4 te GD bau ten the
Us . Statement dottowwing If Ste
Stabernent cone
O gutted , pretid len te
Setpped tha Condition and
Continues he next Shatement.
Fale Exampu =
ED cnulude < Stadio. ns
veld mainc)
bone n3
Pathe t (“enter he neomber’),
Scant (yd, en)
ac 3
Win>o)
Patines (S
te rPuurber
4, Eve nuumees
ei
Enter tee reambe
loo He
th a pede
ee purnben
EPO NIT BenaninesSubject Code/Title: CS 3251- Programming in C Unit:
Hif- cle Statement ~ os
°f else wkalemank eioluatie Uke condition, s te te ue
etaut block wll be exocited , Otharsiat the flalee bLOUe
Pofll be exectrtedt
Syrian » palee.
74 Coon) <>
stmt ts,
Ta
stmt a; [sent 1 (sent 2
include < Stato. h>
Ne tnetude
veld mmalnc>
fine ny Ouepue :-
Paint ® (“enter bho number);
Stand (“yd en);
TF (n>0) is
Palnté (*
ebe
Enter the number
“5
The nambor bg
The Number ts postive’);
Pathe? (“the number & ragattve') ;
Nestea-Y:-
Ty one ch move 4 Abakrren ae embedoled within the
iF Statement es collech Nestect & statement.
NEA! =
14 ( condi ond
F (tendittona)
t
TS (tend thon 3)
Smt 3,
ue
y sem ay
ae
4 Steme |
ee
atrnt 05
2
r DEPARTMENT OF
SCIENCE AND HUMANITIESSubject Code/Title: C5 3281- Programming in C
int arb 65
Panté ( enter Unraeenumben").
Scan} ("dod Ya" ka, bb de);
Bow
“4 ee
£ panty ‘hh big
€
Paet("e eg)
Pid" & hd! 4)
“painlh(eootig Dy
15 else - tf - hock on
Unit:
Oulpue >
Enter bhass numberk
5 as 38
ch wy
The nested tf Statement becomes complex woken tore
Ae mete than bres Condon «Jn that Bttuatten ut canbe
Maprusented tn ft-elve- Y ladder aontwol abauckure.
Syntau:-
+ Coond 1)
Gero |
ebeif (cond a)
Strmt &y
they (cond 2)
Stmts
Cle =
deyattll Stroy
PARTMENT OF
Ea eat SHO RU Mantries:Subject Code/Title: CS 3281- Programming in C Unit:
€ les
te nclurdt ¢oealto.h>
Veta matac) :
Enter Hee ove rras.
the Ova’,
Pants Mantor the avg mene) bs
TF lavg>ae) br Gsoda.
paint ("0 Grok"),
thei (avg > 80)
«, PAintt (“pt Grads’)
Chetlavg > 10)
Painef (*R Grace")
eleely (avg >60)
_ Paine ("B+ Groote")
Clely (avg >=S0)
Pathe? ("B Grate")
Paine $ (" gate)
Sitch cose bbabement
Tht 2wikch utatrrunt aA multiple br
[decision maueing > Skctemaent~ The aucitth utaterenk gatele ow
Reaticutas Group % Akakemane giom 4eveal amtatke qreupg.
EON.
Switch (exp)
Case eoruélt Stee 5
bavales
Coxe cork as sent;
: brows
Sng Crrutbis,
Agyoutk . Stmey
4 a
Example!
#includs< secble-h>
Vota maint)
tee Aacbiey
char op,
i LAPD la -Sub\D ge ~naat los
te
i pete EC hen a. Corn volun):
LL
BOBr mere tcc,Subject Code/Title: CS 3251- Programming in C
Scary (pct, OPIS
Paine t (“emer the vatuns);
San Cd Pd" Sa, bbs
SuseLoPD
i
Case 4! fe sats
basak 5
Coan % pea toy
‘AAR 7 casa tSy
| boeak 5
Case’ x". @raxb
4 basak;
Patne$ ("Resch = td" 2).
e 2
ultth baeak utatemenh.
H The diyjottlt Gs optioned
& The Value @ wus
Pater for boating SusitehO Sime !—
# The expursten tn sutkch ubalement musk pecanilgel
Value 1 a charock® constant.
* NO Beal numbers are ured dn eupacution .
Each Gre pow and Aeyault blottt must be beaminateol |
| % NO tne Gare constants are tdenifeal
p X The aditch can bo nested.
bch ernpreriton Be Comparscl ustty the
Coxe Conttank expacss bn onthe Cider pe
Mn the Absenta q brea Abatement
,
| thee aie followed by rrotdued aaes are See curkeol
Unit: ©
AU Ceatemank
DAR PEACE MSaaanrsesSubject CodesTitle: Cs 3251- Programming in C Unit:
| Statemants Again ard again unt tu upedttind cordlt Hen
hotdas ues .
' Loops axe claifad as,
D counter Conbralled doops
2) Gentinad conk-coltd doops
[Coeante Conkacltid oop '-
Sh counter coubsotled vloop ta nuunbex & ikenaors j
Hho be peyormecl Knowon din advan. det ale knew oz |
daginite vupebitton Uoop.
| boopt Ge PAoceu Of apeating Hae ask vee o |
t
i
}
VA Sentinal Cont stntlecl Umop the number e bores the |
tteration Ja to be peyormacl ch not kneton Leyete- dé & abo
as trdeyiet 2,
‘ indefinite aperttion cop.
5 Thee tyre steopicg Statenina |
i Buokite loop HR dots. loop — * for Loop
Th voltle Loop Lb an enki conbclled Leop, berauuise Ha
tenkarct conoliltin 2 plod ab be foub dine | He ode -
jenclesed th the Joop ase niver
| Sgnean:-
tnt Halizatton
ued -
i while C conatitton)
4 g
i becky of the Loop
an
j ine
i 5
i
i
}
|
{
'
por He contact onda ion evoluatu to gales, Gan te aenmrsl
|
|
r
i
t
|Subject Code/Title: C5 3251- Programming in C Unit:
fit tn clucle
Ad maiin()
whe 9 =0
J wokite (ne =):
panet(“hd "nd,
ott
a
do-while loop :-
The dlo-vohile Loop & an exlk conbaviled toop becuse te
bett condittn 4 eualuatedl ak Ke end gy He Loop: Tha body.
por He tecp gett executed atleast one Hime- The best condition
be besuntnated y (5) gemieolon to do-whil. Joop.
nan: =
Initial zation Cxampic =
nitialtxaLion
trclucla 2eed.t- h>
a Tome] eels
t
body @ the Loop ton n=03
incl doc <> 49
Jeohile Cron) s pains (“ed ")n);
nts
4 SRW ine= Ds
ofp :-
i ol234 5
[Ser losp-
Te & a daginila Loop. Je & used to execute a net Qf
Rrabouettons nhipedtadly, UnlL the cordétfon becomes false.
nro
for (snitialization } condition 5 thenemant [checrernant)
z
bedig of the oopSubject Code/Title: cs s281- Programmingin Unit:
c o.
TaBotizakton :- .
de Ue sect to gnttalze pL assign a starting value to he
sboop Counter has alasaciy bean ‘nittatizd
te Inferalt zatton express ton can be wkipped > bak a weriicoton.
vik necens and must be placed.
loop counter. de the
Condi ton !~
Te & Ured bo thete the cond2tfon.
Sntument/ pectement | —
Te Th used to Inrement/olecrement a countervortcble
Proumples-
dFinclude £ Std bo-h>
Void mained
he 4
fori ai; t<=55 744)
ay PMREF hd", 15
ecLepue
j «
Netted for hoop: - waa
The sLoop USAIN tha oop £4 caotled nasted for Loop.
The number @ ‘kexolfons an this lype of wbourctuse evttl
be equal ibe the number @ ikenations fn the outertoo
mule pid Ene number q tkerokiont &
Example
tT the Panga cLeo p.
Hinelucle x seddo. hs
Void maint)
outpuk!—
tne 7,9 5 i.
for(v ae tenastee) 1 2 oe
* patnct (S\n"), Law
For(Jetsge> ay feed
gy PEE CnaY, 9),
JSubject Code/Title: CS 3281- Programming in C Unit:
Unconatttonal Utatement
The urconditfonal ubatement router the eontaol
Prom ona pothe ke anoktex Lsithout casi | any.
condition p
% geto
* break
* Continue
igre ubakement!
The goto ubatement Bs ured to baanch Uneandttforally
Jfaom one poche ko another pot wn Ehe Program.
oko Utatermnt equi a dobel Sn eider to identi
ictus, zstato-n> aH
Vota maint presale
ib
te acsoje2g05; PPG
lary:
oto bigs
aud d° A)
pathes (a & big"),
bias
aes Cn & bt")
DEH Ured FO beaminate the oop, uohen ba. kespioad
baeok Ge ud untide any te! Joop, conkurot Ee
[outormattestty,
a baonijsad ub the Soak atatemant after
Joop -
= tt cluds 2etdfo.h>
bacok Void maint) ofp.
1
Hels
for (Ta\5 te sji+)
GC 23)
: Souaty
4 BEL CUA 5
DEPARTMENT oF
SCIENCE AND HUMAMITiESContinue Searemant
é &
The continue statement ws ured bo continue ner
fp the ,
Tkeaation g sdeop seaternent, voken Te occurs sh Loop
Lo mank afer
LE does net werminate but Te tip & kate.
Gis utatement Gxaionpie 2
Sgntan: tb rclucle cstdin . h>
Continua Void mata.)
+
Gre ts
ontpak: For CP =| steno tet)
U
2 Xa 3)
4 contuiue 5
Ss
PLEO a", Ts
4
J
Pierro ~Diret vee:
The pruparocessor as the name Emplite, Ce a Paogian
Enat Procerset the Source cole beyore TE parses Hacugh
te compiler.
The Paspro caning farguage. confik of dikectives
f be reented ancl metros bo be exparded «
K Inetusion oF header tele
# Ma0 expansion
# CorciionaL compilation
® Othtn dinreifves
Tncluston of Heacter flee: -
A headltr $7 ts a file contatnig « Aeckoratins arc
MAVD datinitfons bo be 0 be avenal douse,
Hla -CS3251 / PROGRAMMING IN C UNIT:
Nested Macro - ~
The macros dleyenad usittin
mano
Aayintedons bo our ounce program Waging 8 5
Syreax: i ccm #duying B BES
include filname opetan. ike tees
wohen the He fe included th a
Jee compu Chan oyett Uke
aro. Sa
& veanchedt ony & StarcarcL| dagietlen, dates eee
dite ctates . formal paramerert within
Macros: Parenchests | Sepasacecl “e
commax .
Synta:-
A mato & a fragment of
oda stich has been goer o
Name. Whentver the name &
ee F deere ia roname(paramuteril
xd te oh
Example: -
ARthelucle 2 stetfo.h>
Holetine Sqetx> day x)
Void matt)
Laced by Ek. contents oapla ces ot
ht a=6
tage Chxleney Pate F$(aren= ted, nga),
(sbathg/infeges)
The Paeprocatoy aacegltia Lona tora compilation : |
He AER, speci ty A cendittonalh ta dbucHve
7 Matrag
This tk commonly ured bof AOE Lohechin, OT rot bo
tga Sgenbotte contarve - Prebucke Achunk gy toda tn ¥
Adagins age 18 Final token ubwom pared bo
s v the compiler .
Houging Ph 34 Hifdey Afrcettve: .
The #Hifoley Ce the Bunplst
AE a Corditfonak prsprou
land ur o. Vater rerective auct Ce Used bo Check
A che Seed pageant for the eydtente of mao
# chettne tdantifier (1,2, dayint ten -
DEPARTMENT OF
F SEENECAND NOMnniriesCS3251 / PROGRAMMING IN C
Syntax!
Abge def macro
conbroltad Lex
Pedy
Hendley dtrrclive,
Thee png
Sprestee Of Hrifdey oltre ctfve.
has net been daaytrad et tf 16
Aepintttion has been sernoved
fen #runclip,
ret:
fF Fn Maco
contrcttad
Panaty rotted bexnt
fF dinecttve:
The HY dime ctive Se ured bo
nt rol Eke Compilatton of
rifons Of a chore file.
Syrvow.
dt Y condition
Control lea Lenk
The Helse clinectiye can be
urd witht te eenbuctte bt
bent of a H#If deisettve bo
vide alternative text bo be.
wredl PF Ehe condition ls falee
CS
condstéon
controled Lert
4 else.
contrcilad bent
frend
Akectve Le che
[oervettve .
The Arely Afasctive ds ured
tohen Lhere cas monsthan boo
Wadi ble. alkernatives. The dece¢
[iikecttve ke tho dtelke
JAbeclve f& ombecteledt uslth
HY olimecttve -
i meet
ty eorditton
conkadld KE
HE ely cond
Controlled Lext
Hele,
contour ELE
tencif¢
Hrendt dtrective :
Te & Used to end the
Conditional compilation
OUON AtreckPves
Heanor:
Th & wud to paoduce
Compiler - Ema erro mura e
Seprscves a
af ror
Bedyired
mUNE -
- Fite -
PATE ~
-TIME —
-arpe~
gting
gv
Matro Nome :
“TMESTA MP ~
Depantmes
SENCEAND MUnaanicriesSubject Code/Title: CS 3251- Programming in C
Compr lation Proce ss +-
The Prone & me
| Program and Uinting
¢ Ubaa to perjor Lhe tasks
wi
ws cated execettion af the
Pawgeam +
¢ Propam execrciex On
De te He Procans of convert?
the Keghlevel tanguag? progod
Source progrant statenunG|
Hfgnel ——-tronulatey
| on ena) LP Ceernpit
jhe Abardord ¢ Ub,
Unit; L
luontng tie pacepem
A The ie oes coke Of &
Pre we Untedl ustth
toga thak one readied fot
euecutfon of a
RTE Crater a fot. Lolth ¥en!
extension «
# Te links 2 Uepara
corpilecl functions together.
tte one program .
$Tt combina the funtétons
with;
Ge Obfeacte. a r
[Exeenutton of
SERNEE AND MOmanrries83251 / PROGRAMMING IN C UNIT :Bpstes OF &
PROG RAMMING
‘Tilo marks
I uohar GQ the ‘Importance of kapvoord tn ¢.(av aprlmay nets)
Keyusorda ant rtioswed words whose maontng has
arsed been explained EO the compiler: Thee eons eae
Leo cata stewed coords.
Wohak cle You mean ¢ Token? (aU soa Irene Roa)
The Gmatlest fdividuad unit a cop ams are
Enecn as c qOkens. ep Kepeoorals yickentifiert , conmeank ,
Sey ppAatoss » Spectal characters
xe our He ules bo be followed “4 Pants Prens?
HaAn Vent’ fron mut begth usith a datker (Cet) underscore
RON Uppencate ancl derrorca Utter, are pownitterl
FAnidentttter cannct be any one of bh kuypeoordas
NO Space ant s pectot ty rmbt Bip. obs peltobanients
dente fees
ushak ake Vasfables? Give exampus 2 Cpu may [une 20t6 ) /
Avantable bon Ydantefter tat te wed to uspanent
psome ubpect fred tase GF ejormatvan usithin a desl grated
Portion oF Ee paegaaum.
giample! int sums
IS)eaxite a noe on Segaben storage class 7 (0¥ Ppe [may sole son
4 The wsgtter winsoge Claus suggest brat Le atest to
te diclaud onject Uhould be as fost as possible
4 The olgeck of an clint fre for Uhich Eke ung inten
dh Stored gh cpo rag taker -
eck sill have outomatte -
toroge class bev bean pect heck
y The Ae OEee. atounge clase of
Dor sacs oe
Feuer aN Huma.UNIT: Brstes op
83251 / PROGRAMMI
PROGRAMMING
6) Deine Ieptat tare converston
putt type cowersdon ALLO bran ab cutomah's
Cpo may] tune Anil,
[jp conversion - Te ts clone by tha compiler on TR own ,
fut thot ony exterrrt barqaey from the User.
| Example |
he A= . .
th S, br ao.
Hoat GS
CF athy The desulkant vate ltt be float.
Naive He Une of PAeprocenor (hu Apr frray goir)
Preprocesor wa a taanslator that convert a aU.
Wwattten Zn one Wah luel darguags dinko an equivalent progr
written 29 anothor high bevel bai age +
Bhat G the wre of ray cre, Preprocuor ? (Au nov/pec >
Wayne Be unc ko aime Constant Velie oj
any Of khe basic datatypes -”
can be
co-colile
cohile
In vail, Loop a condition i in clo while loop a CondPifon &
petted at the began q the foratuated act the ond @ bee Loop -
p:
body q tte Loop U nok execu ay Ha stoop WIE be execu
hen ea value q te Condftiin ilar Last’ once euen Ue condition
be. fare.
WAL a for Loop abatermint bo Pathe numbers {om io |
gplnuude 2 gedio why Chu Jon 2014)
vetd mato
we vy
for (atoy 72 yt- >
sed (S na 4)»
Parts a" 1 5
Yer DEPARTMENT OF
FF SEUNTE ANY HUMANITIES