the following formula is used to calculate n n x


The following formula is used to calculate n: n = x * x/(1 - x) . Value x = 0 is used to stop algorithm. Calculation is repeated using values of x until value x = 0 is input. There is also a need to check for error conditions. Values of n and x must be output. Write an algorithm to display this repeated calculation using pseudocode.

NOTE: It's much easier in this illustration to input x first and then loop round doing calculation until eventually x = 0. Due to this, it would be essential to input x twice (which implies inside the loop and outside the loop). If input x occurred only once it would result in a more complicated algorithm.  (Also note in algorithm that <> is used to represent ≠).

A while loop is used here, however a repeatloop would work just as well.    

input x

while x <> 0 do

if x = 1 then print "error"

else n = (x * x)/(1 - x)

print n, x

endif

input x

endwhile

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: the following formula is used to calculate n n x
Reference No:- TGS0355425

Expected delivery within 24 Hours