How to resolve the algorithm Sum and product of an array step by step in the Plain English programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sum and product of an array step by step in the Plain English programming language
Table of Contents
Problem Statement
Compute the sum and product of an array of integers.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sum and product of an array step by step in the Plain English programming language
Source code in the plain programming language
An element is a thing with a number.
To find a sum and a product of some elements:
Put 0 into the sum.
Put 1 into the product.
Get an element from the elements.
Loop.
If the element is nil, exit.
Add the element's number to the sum.
Multiply the product by the element's number.
Put the element's next into the element.
Repeat.
To make some example elements:
If a counter is past 10, exit.
Allocate memory for an element.
Put the counter into the element's number.
Append the element to the example.
Repeat.
A product is a number.
To run:
Start up.
Make some example elements.
Find a sum and a product of the example elements.
Destroy the example elements.
Write "Sum: " then the sum on the console.
Write "Product: " then the product on the console.
Wait for the escape key.
Shut down.
A sum is a number.
You may also check:How to resolve the algorithm Loops/Continue step by step in the Plain English programming language
You may also check:How to resolve the algorithm Write language name in 3D ASCII step by step in the Plain English programming language
You may also check:How to resolve the algorithm Determine if a string has all the same characters step by step in the Plain English programming language
You may also check:How to resolve the algorithm Sum of squares step by step in the Plain English programming language
You may also check:How to resolve the algorithm Primality by Wilson's theorem step by step in the Plain English programming language