0 ratings0% found this document useful (0 votes) 44 views21 pagesPrograms On Loops
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
1S
| To print teverse of on intege.
i Y
jer" To design and develop a c-program +0
i vevetSe tht given integer number
| Algorithms:
Step 1! Start
step ® : Peciore ALM, TemP enum, O19
SteP3 * Read Mums
step t * Stose Temp=num and Ranum =o
stepS ‘Repeat step -4 +0 step-7, vahile Temp!=o
do other wise go +o step-2-
steps © Compute using the logic
Dig = Temes: lo
| Revoun = (Revnum*io)+ temP
sremp = TemP/lo
| step 7 ¢ print Rerwum
eeP8 / stop
Source code:
| Heinciude
int maine)
{Line pour, Teme, Rerum, OFF 7
prints C eaiee ony number!) )
seang Ura", pram),
temp = Sum;
j gevnum =o 3
yoniie creme! =D)
| : _
| t Pg 2 Temel 105 .,
Revoum = (pevaum* lo) ¥DIgs
Temp = temPllo;
prime (“Reverse of number ad is 29" wun,
Revnum)',
| yetum D5
3
Scanned with CamScannerpeaere “nur eavnuy Fearn
intialzé
rev 20
] print rev /
s
‘Scanned with CamScanner—
eEE——___ °° ° ° °° °° °° -«¢
Expected inpur +
Enter any number «123
Expected ourPrt ©
Reverse oF pamper 123 16 321
petuay inept
Ener any pum bev 123
pctuas ouredt * /
23 15 3%)
Reverse OF num dey
gesurt +
wena th ¢- Pf
of th giwin number
gram +0 detesmmae the Teves?
yeroped Od
ss cuccessfungy de
executed «
Scanned with CamScanner| I I
16 ,
To " ,
eprint =muitiplecatron table
Lai:
| Te i
| jo desiga and develop @ c- program +o print
;the munipiecation table
| pigorthen :
| step 1: stark
| ia
| arePr 2 Read num s,d;5
step 3 § compute
fetes i )
for U=
j= nami 5
step + > prseiay DN, indy
ster > StoP
source code:
qrinclude cSt Yo-n>
int maind)
{int nue, 1,9)
printhc” yn 277
printé C'\o Enser t
meant (hy. tPA
[Hplecatyon dableece'J5
pe nuUMbee me)
prints Cin 74 MutTPLiCATION TPBLE "nara
printf C'.. ")
por (iets Fe=t05 i++)
Lye mums
prinst Cyd? 7 a", mum 4129)
3 " n
print e C1095
yexurn 0)
Scanned with CamScannerom
pLowcHART
Scanned with CamScannereEeE7"__ ..... .»«;«*-F
[expected input :
err mureiprecaron table
3
2ce
Enter the number
grpected output
ah =3
ate
343
gta ott
gts 2
e218
#y =e)
ag <2
3¥q 22!
ilo 230
3
3
actual In put .
election gable oe
77? muti
| enter the 7
| pceuat urea
per *3
we3 f
ye |
xz 2%
oon alt ~
| ts 20
| 3s a8
3h 20
38 22%
3t4 291
| nie = 20
| Resuit:
\ hence th c-program = 48 prim) th murtiplicad ion
Lope of O gimp 1
deverop (A an ene cued
umber 1S succe ssfary
Scanned with CamScannerNS
Vis To find factorial of ao numbe
Y
To design and develop ac-program to fied
the factonal of a given numberln).
Algor'thm :
Step |: Start
step 2% : peciare i,n , fact
steP 3 + Reain
ghee 4 t intioize I= V5 fac!
Repeat step-§ and steP-7 vohile in
ster S
athirwise go to ster -§
geep-6 5 tata y
seep? i face = factti go &O ser 6
ekerp B EPeINY Fach
SkOP
ster 9
source code!
gp include esedio:h 7
int main 0)
fet, My fack='5
| { ine
out "D>
prinvecEentey Nv
| sean (Sra, #997
3
\ erintt C“facrorvat is = 7.a, Fach)s
| yerurn OF
3
Scanned with CamScannerplow HART
Geax*
| peciare in, tact |
i]
GD
4
Scanned with CamScannerBO me
Expected mpub -
Enter n voiue +5
gupecteda oveErdt:
vs
actor! = 120
poruar inpat *
Ener np youre =5
petal output:
Factorial ts =120
Resurt:
fience, te c-proyram £0 Find the facioxiay oF
was successfully exncum
inpurs cand owspsas
a and
numbey
ao given
the dee
develop <4 fort
Scanned with CamScanner|
13 Y
To print prime numbers
. between
wire: e& lon
To v4
. design and develop a c-program
enor prime numbers perween
pigorithm:
40
lanan
step! | Start
step? ‘peaare j,J,n, count variables
ster 3 Read n varut
step% | Initiaize isl
so: ;
ster TF len goto steP-6 ese goto ad
steeb count =o
seep? rpitiovze Jo)
stepS TE jezi JO ster-d else goto steple
steed | EE i7-J= 0 go 40 SteP-10 ee goto
step -0.
step lo + count = counk +! (update expression)
3ter! !yajel and go to ste -8
ster i? | If count==2 goto step-13 else go to \
Sskep-lt.
step 3 print)
eter It : jell go to step -S
step is ¢ StOP
Scanned with CamScannerFLOW CHART
pally
[_vecare Von, count |
Scanned with CamScanneret
source code:
|p inciude 2Stadiorh >
| int main
{ ine i3,n, count 5
piinte Center n vayun "D5
scang (yd, 20;
print Cap, prime numbers upto 7
ne
for Gheryig=ny ita)
count 204
fore ge) Jeet gate)
i
ie ind = =o)
count +)
J
TE (count = =27
pane Corde" 305
| 3
very 0%,
Bupected input ©
| Enter N voiue : 16
expecta our Pat?
| z
i 3
| a
| 1
[actus ineut
Entex 9 vo\us * 16
actuar our eur:
Abie
e the e¢- program £0 print the
1ton Was succ S5-fU ly
| Resurt: pend
prime numbers between
execusra for aAvFfesent votues of in
Scanned with CamScanner19 io gel Cl Series
TT nerate = fi bonac numbe
v ' et
o pers
| pim:
To design
pipenace’ sequence apr mverm
“pigoritne *
| step 1s Start
eer b / pecate a,b, 6, 1,9
Dee met
geet? aro, b>? axe inivaized
seers 717%
| geen 4 2 err ay
| gop i eniie fer sevens svets 7°)
ster 8 se caxP
stepa : PANES
exer © 7?
| seer
| ke P12 a
| exer 13 : geo?
source code:
ge inciuds estdionh?
ine main U
‘ wnt <0 peri edserns
pains Center & umber)
secant a" 2)?
prin Cra ah, aos
while Cicer)
{ cearey
prints 3,02)
azb)
bee)
perl
reaurn 04
_ 4
Scanned with CamScannerFLOWwcHART
stort
ee
Declare a,b, 63) |
Scanned with CamScannerexpected input:
Enter vais +5
Expected ourput:
O112 3 is the ourpur
actual input:
Emev fn veut =
Ackuc) ouput *
o11le3 is the output
pesuit!
Wen& th e-program +o print the fibonaas
. Q
geneS jg succe ssfuly aeveror (8 nt eens
Scanned with CamScannergo. SUM of individual digits
Aim *
To
of individual digits of an
write a c-program 4o find the sum
integers
i plgorithms :
| step i: Start
gead num,sum=o
gteP 2
Pywonile pum 20
| ster 3
| ienum1los
| sum =sum +15
num = num/ios
: pisplay the sum of digits of +h
| seept
number
| grees * stoP
source code?
| Hincluarcstdio: or
|
int main)
{ink pum, sum =o.
| pate (Venter ot mara ver 9
| seant Cra", POUND)
| yohile (num 7°)
|
| f; 5
| yenum yo >
| gam 2 sum)
| ‘
| num = 4m lod
, a
prinef ("sum of digits of number: do", Sam;
| rexurn D)
| 3
Scanned with CamScannerFLOW cHORT
Scanned with CamScanner“| expected input:
Entev oO number : 246
gupecttd Output +
SUM of digits of numbe 11%
actual input *
Enter o pumper 1246
ACH) = oUtPUd ®
sum of digits of number 212
Qesuit + ; sue se
Hence, the c-program 40 find +
\ one i. ececuxed by
Jindivraua) digntS is successfunry pane
faxing the inputs and gerting
Scanned with CamScanner“(gt + palindrome — checker
To wit a c-program +o find the sum oF
| individual digits of whathy giuen input VS
polndromt of not
| geeet: Stare
| sxep2' decaor®
| -gkrepB' read a
grep 4? assign m valut *o temP
p, tr, sum=o, temP 7
| seers’ Whilt Cn>0)
T]envio
| Sum = (sum*® jo) +
D=nho
ster 6 3 TF temp == sum diselay patinarons ee
nok pAiNaome -
stor
# indute ce¥sionn?
ink mainO
L int n,Trsum =o, tem Py
pringg (Senses tH num be ',
seanf Ca", #9)
temp=
| white (n20)
| { peniios
| sum = (sum*ia 1S
| n=nloy
| ie teme == S44)
| prin patindiomt num very)
ese ee rot parindrome! yy
| rerun 07
i 1 j
am i
Scanned with CamScannerFlow chart
fo a
dedare 2,
r gum=0, tem
Tentlo
sum= (sam* io )+¥
dis, poy
nor parinacom !
Scanned with CamScanner——
\ g
input?
num ber
expected
enter the
expectet ourestt =
Faceucs input’
enter the number
actual OutP ut:
pan dso
| pesutt:
| pena 4h c- Progra”
sucessfuNny eucued PY
geting ourputs:
e\
ponind rome num ber
eee
me num ver
to chic panndrom te
yaxing th TN PUTS and
Scanned with CamScanner