Alt Class – Introduction to narrative algorithms using a full example

See the example below

Problem: Create a solution to find the area of a circle.

Problem Definition: Create a program which prompts the user to enter the radius of a circle, and outputs its area.

Algorithm in narrative form:

1. Welcome the user and proceed to prompt the user to enter the radius of the circle.

2. Store the entered radius in a variable.

3. Use the formula for the area of a circle: Area = π × radius² (where π is approximately 3.14159).

4. Calculate the area by squaring the radius and multiplying the result by π.

5. Output the calculated area of the circle to the user.

6. End the program with a thank you message.

Algorithm in Pseudocode:

START
    R ← 0
    AREA ← 0
    pi ← 3.14159    
    OUTPUT "Welcome to the Area of a Circle Calculator"    
    OUTPUT "Please enter the radius of the circle:"
    INPUT R    
    AREA ← pi * (R * R)    
    OUTPUT "The area of the circle is: ", AREA    
    OUTPUT "Thank you for using the calculator!"
STOP

See Flowgorithm File And flowchart graphic here: https://drive.google.com/drive/folders/1Lbf_A-SdV5F4P1YEFui1scGLc3FGVFG1?usp=sharing

© 2024  Vedesh Kungebeharry. All rights reserved. 

Leave a comment