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: DISPLAY

Reads two values, determine the largest, and prints the value with an identifying message. All variables are assumed to be integer.
Read(VAL1, VAL2) (Input the values)
If VAL1>VAL2 (Start loop)
then MAX   VAL1
Write(‘FIRST VALUE IS LARGEST’) (output)
else MAX   VAL2
Write(‘SECOND VALUE IS LARGEST’) (output)
Write(‘LARGEST VALUE IS’, MAX) (output)
Exit (Finished)

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin