Procedures & Functions
1. Identify whether the given pseudocode is procedure or function,
FUNCTION SquareNumber(number)
RETURN number * number
END FUNCTION
2. Write a procedure in pseudocode called DisplayWelcome that outputs:
"Welcome to the Student Portal!"
Then, show how it would be called in the main program.
3. Write a procedure called GreetUser that accepts a name as a parameter and outputs:
"Hello, [Name]!"
Demonstrate how you would call this procedure for someone named "Yara".
4. The following function has an error. Identify and correct it.
FUNCTION Multiply(a, b)
result ← a * b
END FUNCTION
5. Write a function called GetDiscountPrice(price) that returns 90% of the price. Then, write a
procedure called DisplayDiscount that takes a price, calls the function, and displays the
discounted price.
6. You are writing a program for a bookstore. Create a function CalculateTotal(price, quantity)
that returns the total cost. Then, create a procedure PrintReceipt(title, total) that outputs the
book title and total cost. Demonstrate how both would be used together.
7. A student wrote a pseudocode segment that asks the user for two numbers and displays the
larger one. Should this be implemented as a procedure or a function? Justify your answer and
provide the appropriate pseudocode
8. Design a function IsPrime(number) that returns TRUE if a number is prime. Then a procedure
CheckListOfNumbers() that uses the function.