Write an algorithm to display this repeated calculation, Data Structure & Algorithms

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

 

Posted Date: 9/11/2013 3:57:28 AM | Location : United States







Related Discussions:- Write an algorithm to display this repeated calculation, Assignment Help, Ask Question on Write an algorithm to display this repeated calculation, Get Answer, Expert's Help, Write an algorithm to display this repeated calculation Discussions

Write discussion on Write an algorithm to display this repeated calculation
Your posts are moderated
Related Questions
Write a function that performs the integer mod function. Given the previous functions you have implemented already, this one should be a piece of cake. This function will find the

Primitive Data Structure These are the basic structure and are directly operated upon by the machine instructions. These in general have dissimilar representations on different

What are the languages which support assertions Languages which support assertions often provide different levels of support. For instance, Java has an assert statement which t

Explain about greedy technique The  greedy  method  suggests  constructing  a   solution  to  an  optimization  problem   by  a sequence of steps, every expanding a partially c

Write an algorithm to add an element at the end of circular linked list.   Algorithm to Add the Element at the End of Circular Linked List. IINSENDCLL( INFO, LINK, START, A

what algorithms can i use for the above title in my project desing and implmentation of road transport booking system

Objective The goal of this project is to extend and implement an algorithm presented in the course and to apply notions introduced by the course to this program/algorithm. The ass

Ask question #Minimum 1Mark each of the following statements as valid or invalid. If a statement is invalid, explain why. a. current ¼ list; b. temp->link->link ¼ NULL; c. trail->l

Program: Creation of a Circular linked list ALGORITHM (Insertion of an element into a Circular Linked List) Step 1        Begin Step 2      if the list is empty or new

Q. Explain the Hash Tables, Hash function and Hashing Techniques properly?             A n s . H as h Table is explained as follows : A hash table is a data struc