|
This algorithm calculates the value of base raised to exponent. Let us assume we have to compute 74 1.Base ¬ 7 (Initialize base) 2.Exponent ¬ 4 (Initialize exponent) 3.Product ¬ Base (Initialize result) 4.Count ¬ 1 (Initialize loop counter) 5.Repeat thru step 7 while count < exponent (Engage loop to obtain results) 6.Product ¬ Product * Base (recompute result) 7.Count ¬ Count + 1 (Increment counter) 8.Display Base, Exponent, Product (Display result) 9.Halt
Algorithm: DISPLAYReads two
values, determine the largest, and prints the value with an
identifying message. All variables are assumed to be integer.
|
|
|
|
|
|
|
|