C-Programming Assignment-02 QNA - Shadow
C-Programming Assignment-02 QNA - Shadow
Initialsetion
Vaxiable
ofVavable % done at the begining ot he
used n iop.
s
- far' sa initalsatiern paxt
nitialisatien:
ahich Cansi st 3 psts:
-This past all be
exected anly ance
at
at the begiming of lonp
to
cot s trancted
.3
loep
(ovtsl e;thex tncxe /decvemexf
Vasiable.
All
setions of fos loop
aze
• Sepauated by semicolon.
.Al
Au
sections fox loop Qae sptional
be alJays (n such cose
aill
Tue. Žond
We can have nee than
tiatsaton statmemt sepalted
by Comma.
seported by cormma.
Poime ox Not
Checking Togam
#inelude <stdio.h
Void maim);
tnt n,i,p-0,
pintí ("Enten a umbex).
break;
>gce
else
>.laout
J Entex a numbe8: 7
7 5 a Pime Numbes
U- eftned Faetons.
• These axe 4 defesent categosies of uses-defined functns:
Aed pagametey wtlout tun Value
inchde<stdth>
Void add
);
Void maim ()
addc),
printfBye).
void addl)
a=\0;
b=20;
catb;
pintt (a'",).
30
Bye
ac= addc;
pn ("4, ),
30
3vbh aVametes G w:theut eutm value
-l0,
add (a,5);
b-20:
pointí ("Bye)
C-atb;
printt (,);
30
Bye
with Posameteas E
wth Retun Values
#ineude<steih
nt add (imta,int b)
void moinC)
{ nt
$
a,b,c;
b=20;
C= add (&,b).
("Entes No of
,afound-0,a [,
Rrsay Elements:");
Scanf
(/d, &m);
qrintk("Etex
aray elements");
fox
{ (t-0,<n;f+)
skant
(ta"ga]);
pst ("Etex Seanch
lement-")
Scanf 1,&),
high-n-y
whtle (towd-
high)
low = mid+l:
else
printf ("'Seaach
Unsucesshr),
)
ef.else statment
Syata
{1f ean d
statmentl,
else
tohnent
;
else
statment
.When seies o decison axe to be made we have teo Use mose than me
execute 5tatment 3 4
. con dl s tve,ae entes nto t bleck ef nestedl
3//Larest of 3 Nmbes:
ttinchdesstda h
iSt a,b,e;
el
gcc
las
>fa.out
Ente 3 4:feert numbeg
23
3s lavqest
{(nsll
etun
un
n
n-)
fadn-);
n
>.la out
3 EnteN a no:3
6
.'8-Second Class
'c'- Thisd (loss
.-Pass Class
Sateh stabent s
Syntax:
suliteh expessfon)
{ case label stobnnt;
bseak;
byeak;
Case label : statmet n;
bxeak,
delauti slalbment;
Label1,label2.- axe
temstter comdant expsessons.
-Case
- The
label ends th coln.
bseak statment at nd ot ach cose bleck ?ndcates end of thst
block fF Causes ev
ext Som
detauH an
epaessin doesnt
opthnal case
match
ahen
süitch
th
ese
statments
any
l
the
be erecubl qf Value
cae values.
- No
Each
2
Case
cases
label
Can
must be unque oeble to xane
have Same label.
- The default Can be placed anyahee
fn switch statmert
Used at end of suiteh statment. but usually
Scanf (4e'",Q);
Sait ch c)
Case 'Sa': points ("
Drskimtian").
byeak;
Case ' :pbint{ ("Fiast clas").
byeak
case B': prints ("Second Class).
case 'e' :
break.
pimt
break;
('Tiad Class),
bseak;
boeak,
gs qade.c
>aout
Fntes fcacte Gsade: G
Distinetton
Suap(.b),
azb;
3Reoxe Suap:a\0,b=20
Aexe Suap a-20,b-10 :
•lIPass b Refesence
#inehude
stdtok>
Vaid slap(nt
Void nam ()
&at&5);
t= *a;
at*a-
+a *b;
*b4;
>.la.out
Befsae swap: a=\0,b=20
Ater Soap:
a-20, b-l0
cene, ts true.then £ y
then
€cond s olse m:kally bedy of loop fs exeded he
st:ti
atleast
body
Once.
of locp il be executed
se ll hat be execueted.
Symtax?
-Smtax
witaltzat;:
ddof
statments
stutnerts; /desenent,
Tneremet
Sraement /eckent;
Joshile Ccondition),
Smt n=l;
whte (n>)
do
print ("Bye);
JBye
Bye
Rbenacci Sebies
#inelude<stdio.h
Votd matn)
{nt n,fl,s-\sres;
point! ("Ente a no:");
Scarf ("1d",n),
points ("d,1a',$,9;
do {
C+t;
}ahie (ca(n))
3Ente a no:5
I|2 3 5
I wte aa c-Psoqtam to sart grem Pn ascendtng ovdo sing
numbexs tn
inude<cttoh>
vod mafnC)
{temp-nulg;
Tum (]:num;;
point("8,al);
nelude<stdto.h)
votd main()
Scav4(&atn
patntf("Entey anayB8emerks:");
Seanf("d", 2al11,1);
('Poduct fhey Denerts)
for(-0;t<2;:++)
fo (ked, k«2;k+)
fos
Guo,t«2,i++)
fo 0t42:+)
2
I 2 3 2|
tinchde <stdto.h>
Void manC)
it'spaceg,80$;
printfEntes numbe of Tous:"),
Seanf
("",&Tous);
fo (:?4-
Xous;?4+)
1 fo(space=1;Space<- XOWs,-i; spasg++)
point (").
fov
(g-l;f4=;j+)
pintf ("w)
| 2
2
3
I
2 I
1]Wrte a Cpogtam to stmulate Simpk caleulato sufth statment
usins
inlude<stdto.h>
void main)
1float
a,b,es;
char opt;
pointf("Entes a b Values:")
pains ('sum: e;
beak.
bxeak;