Algorithm writing Instructions: Algorithms are a generic way of describing a sol
ID: 3888023 • Letter: A
Question
Algorithm writing
Instructions:
Algorithms are a generic way of describing a solution to a computational problem without use of any specific programming language syntax. It cannot be executed on a real computer, but it can model and resemble real programming code. Natural language is used whenever details are unimportant or distracting.
Your algorithm:
Must be unambiguous (exact)…are the steps numbered? …do we always know where to go next or are we left hanging?
Must be correct (solves the problem)…are the ‘requirements’ being met?
Must come to an end (terminate)…how do we know when to end this?
Must be general (for all cases)….can we input any data & still solve the problem?
Must be at the right level of detail….will a computer (in general) understand what we are asking it to do?
Requirements --> Accept as input the 3 dimensions of a box (length, width, and height) and calculate the volume. Print the result.
Explanation / Answer
Algorithm to calculate the volume of a box.
Purpose:- To calculate the volume of box.
Step 1: PROCEDURE calculate_Volume()
Step 2: DECLARE length, width, height, volume as of float data type
Step 3: INPUT length
Step 4: INPUT width
Step 5: INPUT height
Step 6: CALCULATE volume = length * width * height
Step 7: PRINT volume
Step 8: END PROCEDURE
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.