Solved

Pseudocode

Posted on 1998-09-16
3
302 Views
Last Modified: 2010-04-16
Please help me correct all logical errors in the pseudocode below.  It is one of my course work.

    ------------------------------------------------------------
The pseudocode attempts to count the number of positive & negative numbers within 10 locations that are already stored into an array & at the end of process display POS_COUNT and NEG_COUNT.

    Set POSITION to 1
    DO while POSITION <= 10
       Increase POSITION by 1
       if ARRAY (POSITION) > 0 then
          Increase POS_COUNT by 1
       Eles
          Increase NEG_COUNT by 1
       Endif
       Display POS_COUNT, NEG_COUNT
    ENDDO

    ----------------------------------------------------------

Thank you very much in advance.....
0
Comment
Question by:yllee
3 Comments
 
LVL 4

Expert Comment

by:jack_p50
ID: 1215564
Maybe you need to output pos_count and neg_count after ENDDO
0
 
LVL 1

Accepted Solution

by:
ow earned 50 total points
ID: 1215565
Are you sure, that the array index counts from 2 to 11 and does not start at 1 (or 0)?
Besides you should initialize POS_COUNT and NEG_COUNT and display them after the loop (as mentioned by jack_p50).
Maybe you should try:

  Set POS_COUNT to 0
  Set NEG_COUNT to 0
  Set POSITION to 1
  DO while POSITION <= 10
      if ARRAY (POSITION) > 0 then
          Increase POS_COUNT by 1
      Else
          Increase NEG_COUNT by 1
          Endif
      Increase POSITION by 1
      ENDDO
  Display POS_COUNT, NEG_COUNT

0
 

Expert Comment

by:stupidguy23
ID: 1215566
stuff

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ConnectWise and their customers need to ensure critical alerts automatically reach the right person at the right time. MSP superheros efficiently respond to these alerts key is providing automatic, intelligent alerting that generates a complete audi…
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question