Solved

Pseudocode

Posted on 1998-09-15
3
448 Views
Last Modified: 2012-05-04
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 1

Accepted Solution

by:
marvinm earned 100 total points
ID: 1252741
One suggestion: Do not increment POSITION until after you have checked ARRAY(POSITION).

0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6989403
POS_COUNT and NEG_COUNT have no initial value, so you cannot count on the the final result.

So, set the initial value on both variables to zero.
0
 

Author Comment

by:yllee
ID: 7434125
Thank you very much.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

831 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