Methods of Algorithm Description Second Edition to accompany the



Download 110,98 Mb.
bet13/17
Sana31.12.2021
Hajmi110,98 Mb.
#240246
1   ...   9   10   11   12   13   14   15   16   17
Bog'liq
ddddddddddd

Solution
his solution uses sequence, repeat-until, if-then-else and subprogram structures.

7TN Pseudocode



An algorithm to describe a game in which the user tries to guess a number between 1 and 100, using no more than ten guesses.

BEGIN MAINPROGRAM

INITIALISATION

number of guesses is set to 0

GotIt is set to false

END INITIALISATION

generate a secret number using random number generator

REPEAT

get a guess from the user

IF the guess is in range THEN increment the number of guesses check the guess

ELSE

tell the user the guess is out of range

ENDIF

UNTIL guess is correct (GotIt is true) or number of guesses is 10

IF the guess is incorrect (GotIt is false) THEN tell the user they have run out of guesses (=10) tell the user the secret number

ENDIF

END MAINPROGRAM

BEGIN SUBPROGRAM check the guess

IF guess > secret number THEN

tell the user their guess is too big

ELSE

IF guess < secret number THEN tell the user their guess is too small

ELSE

congratulate the user on a correct guess tell them how many guesses they took set GotIt to true

ENDIF

ENDIF

END SUBPROGRAM check the guess


O



Flowchart

An algorithm to describe a game in which the user tries to guess a number between 1 and 100, using no more than ten guesses.





Subprogram






Download 110,98 Mb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   17




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish