04 Control Structures (if, while, for)
04 Control Structures (if, while, for)
rol
Str
uct
ures
MCQ
Q. Quest
ion Cor
rectAnswer
No.
1
2
3
4
5
6
7
8
9
10
11
12
Shor
tAnswerTy
pe
1.Expl
aint
hei
f-
elsecl
ausewi
thanexampl
e.
2.Compar
ewhi
l
eandf
orl
oop.
3.Whati
sinf
ini
tel
oop?Expl
ainwi
thanexampl
e.
4.Expl
aint
heuseofr
angef
unct
ioni
nforl
oop.
5.Whati
snest
edl
oop?
6.Whati
sthedi
ff
erencebet
weenexi
t()andbr
eak?
7.Whati
stheut
il
it
yofpassst
atement
?
Descr
ipt
iveAnswerTy
pe
1.Expl
aini
f,i
f-
else,
andi
f-
eli
f-
elsest
atement
swi
thexampl
es.
2.Expl
aint
heconceptoft
henest
edl
oopwi
thanex
ampl
e.
3.Di
scusst
heuseofbr
eakandcont
inuest
atement
swi
thexampl
es.
4.Expl
aint
heuseofel
secl
ausewi
thl
oops.Whent
heel
secl
ausewi
l
lnotbeexecut
ed?
LabExer
cises
1.Pr
intt
hel
argestoft
hreenumber
s.
2.Fi
ndt
hef
act
ori
alofagi
vennumber
.
3.Fi
ndagi
vennumberi
spr
imenumberornot
.
4.Pr
intMul
ti
pli
cat
ionTabl
eofagi
vennumber
.
5.Ent
ernnumber
sinal
oopandcountnumberofev
ensandnumberofodds.
6.Fi
ndt
hemax
imum numberf
rom al
i
stusi
ngl
oop.
7.Fi
ndandpr
intt
hecommoni
temsf
rom t
wol
i
stsusi
ngl
oop.
8.WAPt
ocheckwhet
heray
eari
sleapy
earornot
.
9.WAPtoi
nputel
ectr
ici
tyuni
tchar
gesandcal
cul
atet
otal
elect
ri
cit
ybi
l
laccor
dingt
o
t
hegi
vencondi
ti
on:
Forfi
rst50uni t
sRs.0.50/unit
Fornext100uni tsRs.0.
75/unit
Fornext100uni tsRs.1.
20/unit
Forunitabove250Rs.1. 50/uni
t
Anaddi t
ionalsurchar
geof20%i saddedt
othebi
l
l.