-DlonEER
Topic
Assignent 3 Page:
Dat 1 3 24
Obj ectivek Leann how to wrte a loOp
6tate met Wsing
Odo while' loot,
Ofor' oot.
1. Write
nattral numbehs om 1 to n and dlso
Þüt thein sum.
leonithm
START
STEf1 Jãke a Vaiasle n and ssgn a
Value to it.
STEP Pint Hdwal mte ttom tto n,
STEPA frit ntegens om 1to n,
STEP3; Coin uously add integes om 1 to
n and þrúnt the suM.
END
Topic Papa
Data
3
DIoncER
Terminal-Eter nunber of tens
Code'
#include <stdio. h)
Outputi 12 3 4 5
S um15 Þri ntt (Eter nember of tem, )
WhileCi<-N
rintt
netwn
(nSum=/.d
O)
);
2. Wsite
s palin doome
acþrogham to check whether a numbo
oh not,
AlyonithM
STARF
tatte o it
SE bt t0ttt ttke its
bivite t
temtinde
STP3Asi4h 4uoien ot ntO to
SEM Asigh thehemainden the
n.
PIOncCR
5
Topic: Page:
Date: 16 03i24
ALgorithm
START
STEPL Take a variable and assign a
to
value it
S tEP 2 Revee he nUm ber,
STEP3check it the oigi nal number an d
evesel h
the number, Dublay
<palindome numben?
STERti thenwise display not a balindrome
n umbeh?
END
Code
#ncdude stdlo.)
int main ()
it neV=O) sem, temp
N um,
krunt(Enter a number, ))
Bcant8L ", & num)
temp= Num
whilenm>o)
Hem=num10
nev=1oevthem
PIOncCR
2
Topic: Page:
Tennal- Een a numer, it tem==he)
Inputt 121 else
rintt (ó palindao me number)
Output- fali'ndrome numbe rintp 6 Not a þalindrome numben)
Fnput 125
a palindrome numbeh 3. White a Phogram to ind
Outtut Not all tactory
o a numbeh.
START
STER1Take Vaiable n a nd assign a
NUe to it
STE Divide n with a numben i.
STEP3 hek the he mainder s zeO.
pisplag .
STEP4Incremeont the value of i by 1.
STEP Reeat the sts 3 and t wntil i is
equal to n.
STOP
4
49
Teminal Erter a numbe,
#indudo <4tdio-h)
Inut, 12
Outtut fatos of 12. 1, 2 3 4 61 int y
Erten
rint
14 Cn7. i==0)
.Ayonithm
SE4 Foke
STEL4
- PIoncCK
Toplc Paga: F1
Dats16 03 24
Tennina: Ente a numben
4. Write a c Þrogham to caleulate actoril
of a m umber.
Agonith m
Outtutatorial=190 START
STER 1 a Value to it,
Take a viable and assign
STERa; Muliry the vatuable by all the number
E3
below it untilheaches 1,
STEP3 Dis play tactoial,
END
Code'
#incude <stdlo
it main03
(Ete
rintt nunberi a
hon (i=, =ji--) i
t=*)
FrintFactonial = /
retwn 0;
-PlonCER
Paga:
Toplc:
Enter a numder:
Teuminal
6. Wite a c branam to check whethen
Ihput 3 a numben is Prime nwnbeh on not,
ALgOrithm
Outputifine nUmben START
8 STEI,Take VAniable and assin vale to it.
Tnput a
STEP2,check it the vaiable
a
is divisible by a
Not a rime numben
Output number other than 1 ant the nUnber
itself DisFla y'not a rine number
STEP3 othenwise dislay þrime nemben',
END
odei
#iNdude<otdioh
t man
rintG(Eter a nLmbes?)
BCantSZa", & num);
+onC i=
zdit(wM7, ==O)$
Num-1, itt)$
(Not a prime nenber))
Þrintt
bheak
tnint rine numbet)
hetwn0
P1OncER
-
Toplc:
7 Wte a C phoam to Pru nt al
Pime numbens between 1 to n.
Alsorithm
STEB
START
STEP Take a Vaiiable n
vaue to it
STEP heek t the numbersbetween
prine NUm bers,
STER3: Display the ine nmbers,
ENO
-PIoncCR
Paga:
Toplc:
Data 16 o3'24
Teminall- Erter the nember f tem
Codet
Irputi 11 #includo cstdio
Vojd main)
printt ( ENter the numben of termy
Printt (B6Phime numbens );
ton t=) ik=nj itt)
Åt Pnme =
it (i2j=0)
Frime= 0,
breakj
it (Rrume=z)
Topic
Pags: a
DIoncER
8. Wnite
umben
acp04ran
is Amstnong numbes
to check
o
Whethen
not.
a
Algorithm
START
sTEPITake a vAiable. artAigh a valla
tot.
STEP2; Check it he sum ot digits raisel
to the the inþ t vallle s
powen of
eaual to the value. Display
SANmst nong nuYn ben
STEP3 Ohen
wise dsplay 66 Not an Ahmstoly
umbe
END
3)
PInCER
Pago:
Toplc
:
Dato613 24
lenmin al Eten a nuMber;
#cude <stlioh
Outtut mnsthong numhen #indlude <math h
Input- 150 Irt nun, orig, rest=0 nenainder, nz0;
Output Not an mstong numbr rint Enten a numbe, ")
scant(“/. ",k num);
Orig=num
whle (orig >o)
orig=onig/10;
tt;
orig=um
While(oig>o) $
nem ainder =oi9 7.10
nest= nesutpoN Coni, n
if
(resut=num)
PAiN Aistong nuMbe'
else
trinttNot an A msthong numbe
60
PIoncCR
Toplc :
Dato:
9 Wite a c togan to check Whetheh
d mben s ferect nunben on not,
Algonithn
ST AKT
STEP1 Take a Viabl and asig n a
V alle to it.
STEP2 Check i #he value equal to
e sum of it factons elcudihg
the value itsell. pistlay 6 penfect
STER3 Othenwisc, distly not a prime
humbes
END
PIoncCR
Toplc Page:
Dato 16 ? 2t
Erten a numbon
Tenminal
odes
Tnput 6 #indude sdio h)
n amhen Void main ()
Qutfut fontect iM num, suMz0,
ritt Steh a numbe:
scant (ZA"knu
Not a renect nunhen fonlint iz1; ica NUm/ itt)
Outputi
elše
frunto Not a eect numbe
PIonccR
Pago:
Toplc
Dato:16 03 24
1
10. Write a c progam to check
Whethen a numbe is Stron numben
START
STEM: Take a vaiable and assin a valeto
SCEP2,Ceck it tho sun of the factorial
ot s digts is equal to the value,
Display Sthong numhon
STER3 Othenwise display Not a strony numde
END
Code
#irude <stdio- h
Ant man0
it num, oig hem
Ant est= i=4, f=4j
Rhintt End-ei a umber)
ScantCd? & num
ortg = num
While Coný 0)
Jem= 0ug /1O,
Ohug =0hig /10
(66
Pago
Toplc:
1erminal:Erten a numden;
Tnput 45
Outut Strong numbeh itt
Inut150 1LGeswt==num)
Not a strong umben
Outputi else
PuntFC Not a strong nun ben'
hetn 0;
4, Wite a Þnogam to i vtttte
at prirt Fibo nácci Aeies uto
n
tems,
Al20rithm
START
STER1;Take a Vaidt deNand aigh a Velue
to it
STEPA Take O and 1 as initial twote ns
STER3; Add the two tems to get the hext
tems, Add that tem to the preioLy
erm to getthe net *em. Cortin ue
the pcess pto nth tem,
(68)
-D19nCCR
Topic
Ds 16 3 24
Tenminal Ente nunbeh ot tenng' STEM:DBplay al the tehns.
ENO
Code'
Input 6 #include <stdio-k)
it a=0, b=1 cz0,
(Een
Printt
j terms
Outtut Fibonacci sehies; O 112 3 5 n u nben ot );
tonli=9 i<n, iHE
C20tb,
follainfArie
DIoncER
Toplc Pago 73
Dato 160324
SFARH
te
SEf
12, Wrte a c Phogra m to nd Vaue
whee
AL20ith m
START
and assigh a
Vae to it.
STEP2:Eind the Value
TEP3
ENO
Pelay the value .
PloncCR
-
Poge
Topic
Dato161324
Cole
t 4n #inçlu destdoh
Tenmi haly1+1/t/3-t Vold nan0
ENen te Value of h
Hodtt yJ=0;
Pntty=1t4/9+/3 t.rt/n'
Pnint 4|NENter tho value of n )
Output9983734 ton (i1; ic,itt)
y t1i;
13 White a C ogam to nd he
Value ot sin seies i.e.
Algortth n
STAKT
STEP 1Tae a Variables,H= and assign a
vaes to then,
STEP Eid the Vallle ot
STEP3 Dsplay the vAle y.
STOP
PIoncCR
Topic: Page: 7
Date: 6O324
Et-er X, Code'
Teminal' includecstdioh
tnput' 2 #include cmathh)
yoid m ainl)
Tenminal'- Enteen
n tloat
Outfutiy= 0:90?29%
int i t1j
tAoat y
totint
Fonli=o; i=n,itt)
PIoncER
Toplc: Pago: 79
Dato:16 O31 4
And LCm ot two n ume.
ALfonthm
START
STER1 1ake vauable
two Vals to them,
to
ahd assign
STER ,
Find hCD CHCF) Ot the two nunbey
STER3 Dsplay the sesut.
STEP4: Divide the phoduct of t wo valle
wHh the G7c0 to fnd LCm,
STEP o fhit EH, Duplay LCM,
Code
#ÀNC le tdio.)
Ànt na, n,
ptuintf ( Eten tho n Umoes)
int a n1,=n2
while Cb=)
irt tb)
b=a b
PISNEL
Toninal-Erden two numbery
Tnput- 4 6
Outpu 6c)=2
LCM=12