• C

Pseudocode

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.....
ylleeAsked:
Who is Participating?
 
marvinmConnect With a Mentor Commented:
One suggestion: Do not increment POSITION until after you have checked ARRAY(POSITION).

0
 
TriskelionCommented:
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
 
ylleeAuthor Commented:
Thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.