Solved

Pseudocode

Posted on 1998-09-16
3
304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Canvas.Draw explaination.... 8 4,472
Embarcadero Interbase 9 785
In Delphi VCL, how can you exit without completing all actions? 4 239
Lazarus and Excel formulas via OLE 7 342
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …

739 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