Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting pseudocode with dummy value
    text
    copied!<p>An pseudocode is required to input a series of numbers from the keyboard and to ensure that they are in ascending order even though they need not be consecutive.The number may be positive or negative and will end with a dummy value of 9999. </p> <p>This is a python code I wrote and it works ok,</p> <pre><code>li=[] num=int(raw_input("Enter number")) while num!=9999: li.append(num) num=int(raw_input("Enter number")) new=0 print "Entered sequence is " print li j=0 while j&lt;len(li): for i in range(len(li)-1): value1=li[i] value2=li[i+1] if (value1&gt;value2): new=li[i] li[i]=li[i+1] li[i+1]=new j+=1 print "ordered list is " print li </code></pre> <p>But I have problem in writing this as an algorithm.</p> <p>This is my tried algorithm:</p> <pre><code>Main li list num integer new=0,j=0 integer Begin num=INPUT num. while num&lt;&gt;9999. append num to li. num=INPUT num. ENDWHILE. DISSPLAY "Entered Sequence is". OUTPUT li. while j&lt;(length of li). FOR i=0 to (length of li-2). value1=i th element of li value2=(i+1) th element of li if (value1&gt;value2): new=value1 value1=value2 value2=new ENDIF END FOR j=j+1 ENDWHILE DISPLAY "ORDERED LIST IS" DISPLAY li END END </code></pre> <p>Can I use "<strong>list</strong>" in an algorithm because I think objects as "list" do not appear in every programming language.And shouldn't algorithm be a general code.Same way is it allowed to use arrays in writing an algorithm</p> <p>And <strong>Is it okay to say "value1=ith element in li"</strong>?</p> <p>And how to show that I am assigning the value entered from keyboard to the variable "num"</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload