Professional Documents
Culture Documents
For Loop Activity
For Loop Activity
Header To count the number of time red and green was entered
Declare Colour as String
Num_Green as Integer
Num_Red as Integer
START
Num_Green ← 0
Num_Red ← 0
For counter ← 1 to 10 do
Print “Enter your favourite colour”
Read Colour
If Colour=”Green” then
Num_Green←Num_Green + 1
Elseif Colour=”Red” then
Num_Red←Num_Red + 1
Else
Print “Not recorded”
Endfor
Print “The number of times green was counted is”, Num_Green
Print “The number of times red was counted is”, Num_Red
STOP
3. A pseudocode algorithm that asks the user for the number of persons
within a group. For each person it requests the person’s first name and
last name, and then prints out the full name with a message.
START
Print “Enter the number of people in your group”
Read num1
For counter ←1 to num1 do
Print “Enter your first name and last name”
Read person_name
Print “Hello”, person_name, “Welcome”
Endfor
STOP
4. Write a pseudocode algorithm that reads in N numbers and keeps a
running total of their sum as it reads them. The value of N is to be
supplied by the user.
START
Sum ← 0
Print “How many numbers would you like to calculate?”
Read N
For counter ← 1 to N do
Print “Enter Number”
Read num
Sum ← Sum + num
Endfor
Print “The total numbers used are” N
Print “The total of all numbers is” Sum
STOP
5. Write an algorithm that will find the largest of a series of 100 numbers.
Print the largest of all the numbers entered.
START
Print “Enter 2 numbers”
Read num1
Read num2
If num1 >= num2 then
Largest ← num1
Elseif num1 < num2 then
Largest ← num2
Else
Print “Invalid”
For counter ← 1 to 100 do
Print “Enter 98 numbers”
Read number
If number >= Largest then
Largest ← number
Elseif number< Largest then
Print “Not large enough”
Else
Print “Invalid”
Endfor
Print “The Largest number is”, Largest
STOP