Assignment 3
Assignment 3
Topic
Assignent 3 Page:
Dat 1 3 24
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
rintt
netwn
(nSum=/.d
O)
);
2. Wsite
s palin doome
acþrogham to check whether a numbo
oh not,
AlyonithM
STARF
tatte o it
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:
START
STER1Take Vaiable n a nd assign a
NUe to it
STE Divide n with a numben i.
4
49
14 Cn7. i==0)
.Ayonithm
SE4 Foke
STEL4
- PIoncCK
Toplc Paga: F1
Dats16 03 24
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
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
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)$
Toplc:
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
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
3)
PInCER
Pago:
Toplc
:
Dato613 24
lenmin al Eten a nuMber;
#cude <stlioh
Outtut mnsthong numhen #indlude <math h
60
PIoncCR
Toplc :
Dato:
V alle to it.
STEP2 Check i #he value equal to
e sum of it factons elcudihg
the value itsell. pistlay 6 penfect
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
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
(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 );
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
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
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