Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Question 4

Write a pseudocode that prompts the user to enter their age and output “you are old” if the age is
greater than or equal to 50. Otherwise “You are young”

Start

Declare age as integer

Write “Enter age here”

Read age

If age >= 50 then

Print “You are old”

Else

Print “You are young”

Endif

Stop

Start

Declare age as integer

Write “Enter age here”

Read age

YES NO
Is age >= 50

Print “You are old” Print “You are young”


Stop

Question 5

Prompt the user to enter three grades and find their average if the average is less than 60 then output
“Fail” otherwise “Pass”

Start

Declare grade1, grade2, grade3, avg as real

Write ‘Enter grades here”

Read grades

Average  grade1 + grade2 + grade3 / 3

If Avg < 60 then

Print “Fail”

Else

Print “Pass”

Endif

Stop

Start

Declare grade1, grade2,


grade3, avg as real

Write “Enter grades


here”
Read grades

Average  grade1 + grade2 + grade3 /


3

YES NO
Is avg < 60

Print “Fail” Print “Pass”

Stop
Question 1

Write a pseudocode that prompts a user to enter a number. If the number is greater than 1 then
calculate and output the square of the number

Start

Declare num, squared num as integer

Write “Enter number here”

Read num

Squared Number num*num

If num > 1 then

Print “Squared Number”

Endif

Stop

Question 2

Write an algorithm that prompts the user or two numbers and find the larger of the two. (i.e) if the first
number is greater than the second number output “first number is greater”, otherwise output “second
number is greater.”

Start

Declare num1, num2 as integer

Write “Enter num1 and num2 here”

Read num1, num2

If num1> num2 then

Print “First number is greater”

Else

Print “Second number is greater”

Endif

Stop

You might also like