Solved

Pseudocode

Posted on 1998-09-16
3
301 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This problem is more common than not and I will show you some things to check to solve this problem.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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