Okay, so I'm a 7 month experienced programmer in C++, and now is the time when I am having the most trouble. So my Professor wants us to create a program that asks the user to input a sequence of numbers and then convert those numbers into outputs of "how many positive, negative, and zero entries; what number was entered most frequently and how many times it was entered; and how many total numbers were entered; and use 9999 to stop inputting numbers." I cannot use an array to do this and I'm having trouble finding the mode without an array. Here's my algorithm so far:

Inputs:
number

Outputs: 
total numbers
sum
positive
negative
zero
most number
times entered

1. INPUT number
2. REPEAT when number is not 9999
3.     sum = sum + number
4.     total numbers = total numbers + 1
5.     IF number is greater than 0
            positive = positive + 1
6.     END-IF
7.     IF number is less than 0
            negative = negative + 1
8.     END-IF
9. IF number is equal to 0
zero = zero + 1
10. END-IF

And that's it for my pseudocode, I've tried as many things as I could think of to do as such as asking the user how many variables they would like to enter and so forth. Please help me. Thank you in advance!

your professor prohibitied the use of arrays, but there are many other data structures you could consider, such as string, vector, linked-list, queue, deque, and list. (cstring could be considered use of an array)

Edited 5 Years Ago by Clinton Portis: n/a

Problem is, we have never covered any of those structures :/ she said we could use a function, but I'm not sure how I would set it up.

I think if you actually tested the code rather than an algorithm for it and showed it here I would've understood it a little bit more(the source code you'd be using).

But no offense.....

Yeah, I agree with the above. Post some C++ code and you might get more help.

Also, as Clinton Portis said, you should clarify the "don't use arrays" clause with your professor. Does this mean just C-style arrays, or all array-like structures (i.e. std::vector , std::map , etc)? If you can't use any array-like structure, then this becomes very hard, so I shouldn't think that this is the case. Get clarification :)

Finally, I made a code snippet about finding the mode of some list of integers here. Hope that helps.

Edited 5 Years Ago by ravenous: n/a

This article has been dead for over six months. Start a new discussion instead.