0% found this document useful (0 votes)
19 views1 page

ProceduresFunctions Worksheet1

The document outlines various tasks related to pseudocode, including identifying procedures and functions, writing specific pseudocode examples, and correcting errors in provided code. It includes instructions for creating functions like SquareNumber, Multiply, GetDiscountPrice, and IsPrime, as well as procedures like DisplayWelcome and GreetUser. Additionally, it discusses the implementation of user input and output in pseudocode for practical applications.

Uploaded by

piyushee24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

ProceduresFunctions Worksheet1

The document outlines various tasks related to pseudocode, including identifying procedures and functions, writing specific pseudocode examples, and correcting errors in provided code. It includes instructions for creating functions like SquareNumber, Multiply, GetDiscountPrice, and IsPrime, as well as procedures like DisplayWelcome and GreetUser. Additionally, it discusses the implementation of user input and output in pseudocode for practical applications.

Uploaded by

piyushee24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

You might also like