0% found this document useful (0 votes)
16 views

Pseudocode_Examples_Procedures_Functions_Corrected

Uploaded by

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

Pseudocode_Examples_Procedures_Functions_Corrected

Uploaded by

ekta sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Pseudocode Examples for

Procedures and Functions


With Real-World Applications
Example 1: Welcome Message
• Scenario: Display a personalized message
when a user logs in.

• Pseudocode:
• PROCEDURE WelcomeMessage(username)
• currentDate = GetCurrentDate()
• PRINT "Hello, " + username + "! Today's date
is: " + currentDate
• PRINT "Welcome to the learning portal!"
Example 2: Physics Energy
Calculation
• Scenario: Calculate energy using E = mc^2.

• Pseudocode:
• FUNCTION CalculateEnergy(mass,
speed_of_light)
• RETURN mass * speed_of_light *
speed_of_light
• END FUNCTION
Example 3: Rectangle Area
Calculation
• Scenario: Calculate the area of a rectangular
room.

• Pseudocode:
• FUNCTION CalculateArea(length, width)
• RETURN length * width
• END FUNCTION

• PROCEDURE DisplayRoomArea(length, width)


Example 4: Multiplication Table
Generator
• Scenario: Generate a multiplication table for
students.

• Pseudocode:
• PROCEDURE
GenerateMultiplicationTable(number)
• PRINT "Multiplication Table for " + number +
":"
• FOR i FROM 1 TO 10
Example 5: Shopping Cart
Calculation
• Scenario: Calculate the total price of items in a
shopping cart.

• Pseudocode:
• FUNCTION CalculateTotal(cart)
• total = 0
• FOR item IN cart
• total = total + item.price
• END FOR
Example 6: Factorial Calculation
• Scenario: Calculate factorial for permutations.

• Pseudocode:
• FUNCTION Factorial(number)
• IF number = 0 OR number = 1 THEN
• RETURN 1
• ELSE
• RETURN number * Factorial(number - 1)
• END IF

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy