#7
for number : 1 .. 34
colourback (green)
colour (yellow)
delay (500)
put repeat ("*", number)
end for
%extro
colourback (blue)
colour (red)
put "Done!"
#9
var number1 : real
var answer : string
var negative_value : real
loop
put "What is your number? " ..
get number1
if number1 not= 0 then
negative_value := number1 - number1 - number1
put number1, " negative = ", negative_value
put "Continue? (yes/no) " ..
get answer
else
put "Enter valid number!"
end if
exit when answer = "no"
end loop
# 10
% documentation section
% Gather a set of non-zero integers, and
% display both the number of positive
% and the number of negative integers processed.
%declaration section
var number : real
var answer : string
var negative_number_count : int := 0
var positive_number_count : int := 0
% processing section and input section
loop
colourback ( black )
cls
colour ( yellow )
put "Number? : " ..
get number
if number > 0 then
positive_number_count := positive_number_count + 1
elsif number < 0 then
negative_number_count := negative_number_count + 1
else
colour ( white )
put "Enter number that is not 0!"
end if
colour ( purple )
put skip, "Positive number count = ", positive_number_count
colour ( red )
put skip, "Negative number count = ", negative_number_count
colour ( 43 )
put skip, "Continue? (y/n) " ..
get answer
exit when answer = "n" or answer = "N"
end loop
% extro
put skip, "Done!"
I hope this will help my peers proceed with repetition, I will post the rest on my next post, because I did not want to make this post extremely long.
No comments:
Post a Comment