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

C programming theory Assignment 1

Uploaded by

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

C programming theory Assignment 1

Uploaded by

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

Terna Engineering College,Nerul

Q9Explaia heyLoovds identifherc, Variablel


Constant and clata typec uoth
exanple
D kêy oQxde ;- Resexved oordc in proqraming
Hhat ha ve predetined MeanincThert
Cannot be utd aridentitie Cuariblex
namer)
Exanple s intifelseoile
:ldentiAexc i Namer ainen to Vaxiables
tunctions
idenhf them in
arYayr ,etc ued to
prpgYam the
-
ge totalAmowdt,shudentNanme
CAqe,

Variablec i
locatian in
A vCriahle,
memony that hold
ir a gqstogea
value that can
execution.
chanqe duing
Pngran
Eg' iat ag = 26
floatpne = lQ.5
Constanti A contant tat vave
CCunnot be changed
during
execuon paDyram
eg i- int MAX_AGE l00
Data Typer :
Deinec the tupe at
data Qvariable Can s tore
int foY fn teqex
float fox foatinq-
(eq i- S,l0, )
pint numberr
(314)
chax foy
egi-
haxactexc (eq :AE
Terna Engineering College, Nerul
Q2 xplata difexeat ia built libxony
funciaar
Built -in li bxam funcion are
prede tiae
funcianr
hat inCor
pextm otheg lanquaqei)
Soeitie tarkrond
specitic
Qre pa xt Ot astandaxd libray
Here are Sorme exanpler

priatf (0i Ured to print output to


the Conio le

pnntf /Hell o, Woxld :


2 Scant) Ured to toke aput fom
ureX
int
S canf
X

(ud,&x
Sa yt0 Re humr the squae
otanumbex
Toot

loube get= sqrt(25)


Hrestt wtttbe
Terna Engineering College,Nerul
Q3)rite
q340Yite a pDqram to demons trate the
ure eicape sequences

ln C
charactexr
scape seguenes ar
cpecial
ued aide stingc Here'k
simple psugram demon thating

# include < stdio hs

int main )
printf ("Hello, World! \n"
piatf" Thi irtabi t
a

Tabhed text. \n)


prin tf"A back slashl\n ln';
pnattQuot; Douhle qouter|
Cund Single quotec|\a

netumO
Terna
Engineering College,Nerul
Q4)aqram to Aiad AlL
to 20 pime Numhet
<stdio h>
# ioclude

Void
int
naia
num
)
i flaq

tox aum=2; nunc-20num tt)

fox (i= 2i<=Dum/ ;it+)


1tnum i== 0)

brek
F= 0)
pintf(dnum)
Terna Engineering College,Nerul

break i Exits from the loop entire ly


SEtppiq
Skippiag any furtheg iHeyation c

foxintiel :i-5 it+)


HE 5
break/loopoill esmincte
wnen iir 5

Con tinue Skipr thecurrent iterathion.


i
ot the loop and pceed
uith the next iterction.
forCitizl ic=lo itt )
fie=5)
o ntnue; (ipr
5 the priting

pnat fl"dyi
Terna Engineering
College,Nerul
Q6) Difexene behween
Cal Reference
Call by Value Ž

Cal by Vale i Acopy of the acthual


parametea paedto tne
is
fonctian
Chaage
inside
macde' to the
the fuactian parametex
the do not aftcct
Oriqiaal Vaduc
Vaid funchao Ciot x)
X=20 Changes only Iocd

Callbu Beterence i A reference


laddyesto the actual parametex
paised to the
madlred
made' inside the funcionChanges
functian
mede affect Hhe changc
o rqina
Naue

Void funchan (iot *x)


/ Chang erthe
Oriqina tede
Variable
Engineering College, Nerul
Terna
Q) doDifeene
Lhie
beteen hile
loop
loop

conditioa ic checkedL
whileoop: The of te loop ic exc cuted
before the bod
falsefaitialythe
f tae condiian ic
not execut e atal
pMay
while (o oncitian,)
laop bady

looThecondithian ir
it checked
Ldo vohl
ahilz loop The loop
aftey ttae bady of the at
to execute
leastee
boady
d

do
oop bady,
íoile Condihan)
Q8 Acutal Paxametex fomal Paameka
Autal PaTamefer i The actuaalue oY
Vaxiablepassed to a tunchao ohen
it ir aled
Eg i- add l 3,4)-3 and 4 ane the
acutal paxamer
tonma pararmetex :The vaible ia the
functoodetini hoo thateceirer the
actua parame ter yalue
Egi- Noicd
are the
add Cint ayiotb)
foma
2La&b
paranag tea s
Lfunhon body
Terna Engineering College,Nerul
09 BecuxSive functan
SA neurie
ftelf
Calls
finchgiafunctian that

Eq factorial Calcultion wing yecwnnn

#include <stdiohs
int factona (iatn)
Cigt

Kelie (o
ehm n * factonal

int
piatf
m

cd
ain
("d ) tactorial 5)
Output ir 2O
QLo itferent Storoce Clascer
Auto iDefault ttorage clarfor local
variablec. Theae Variablc areCreated wtn
the functioa ic called and cdehnyed when
tne tuncton exitr
Registe riSpecitiec taat tae vaiable
Lshc
chould be stoe d io a cPu Yegiste Y
for faster accesr ( not qraaanteed)
Static :Betainc
behase en tuncháo
tecallwale ofavanable

Cxter; ue declare vaiableS thet


to
aredehned outside the funchan iaanotter
file.
Terna Engineering College,Nerul

QLl'naram to Calcdate te Aeaot Circle

and flooaart
#include <stdish>
# include cmatnih>
iat mcn (0
flaat Yadius
pnottl "'Eatka radiuci)
&xacdiuc)

phatffArea atcirclue %2{\n


314*radiurtYadiu:

ftouohort

Staxt

7tnputYatiur

fOrptoyaea

Exit
Terna Engineering College,Nerul
ct Ghea ambex
Program
g to Add Diqitc
(4so)
# include < stcia h

Int sum=
whileCnum )

Qutput 1241Rt0)
ttouotort
Stas t

fExrct cait nump


Att tt orum t

fRepeatu tilo
Display Sum Exit

You might also like