Counting Pos/Neg/Zero Numbers in array

Ok basically the program is supposed to count all the positive, negative and zero numbers in the array. I tried to do it but the outputs is 0 for all positive, negative and zero numbers. It needs to display that there are 3 positive numbers, 2 negative numbers and 1 zero number. Does anyone want to help me what I did wrong? Thank you!

1
2
3


Last edited on
You want to increment the value pointed to by each pointer variable, so you need to dereference the pointer before calling the ++, for example:

(*ptrPositive)++


Also on line 54 - equality operator is ==, not =.
Last edited on


thank u for pointing out that it should be == and not =. I did not notice that.
Last edited on
It worked thank wildblue!!
Last edited on
For example, at line 46:

Right now the code is trying to increment the pointer.

ptrPositive++;

You want to increment the value pointed to by the pointer, so you need to use the dereference operator * on the pointer to get to the value pointed to, then increment that.

(*ptrPositive)++

Lines 51 and 56 need to change similarly.
check line 15 there
Topic archived. No new replies allowed.