![]() |
|
#1
|
|||
|
|||
Using Arrays to Summarize Survey ResultsI need help from anyone out there who can help explain why this program gets the results for "Frequency". as it does. I do not understand why it's doing what it's doing. The program runs fine, I just do not understand : frequency[ rating ] and why it's giving me that output. The Rating array makes perfect sense.
CPP / C++ / C Code:
Last edited by Nexa : 29-Nov-2004 at 01:11.
Reason: Code error need to fix it
|
|
#2
|
|||
|
|||
|
I noticed you initialized the frequency with an element number of frequencysize, but you only gave it one element. Wouldn't you want to initialize it with all the elements, like so?
CPP / C++ / C Code:
|
|
#3
|
||||
|
||||
|
Well, it's a simple statistical algorithm.
You are right, responses makes perfect sense. You could read it "2 people answered 2, 11 people answered 6..." if you count the "answeres". There are 10 possiblle responses, so the size of the frequency array is 11 (10+ 1). Now, lets look at the piece of code I think you are having trouble with: CPP / C++ / C Code:
First, please observe that answer iterates on the whole responses vector (size = 40 different people interogated). For every answer in the list, the frequency item at the respective position (1 - 10 possible responses; there are no other values in the responses array) is incremented, thus resulting an array(frequency) with the items at the indices representing the number of responses equal to the index (frequency[1] = how many responses of "1", frequency[2] = how many responses of "2" and so on...) There you have it. I hope this isn't such a vague explanation as it seems to me For more questions on this, you are welcome to post back. Best regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#4
|
|||
|
|||
|
Quote:
I'm not really sure Dr. Evil the code is not mine, however I must understand what it is doing in order to finish my assignment. Are you asking if int frequency[frequencySize] = [0,0,0,0,0,0,0,0,0,0,0]; because it is set to 11? |
|
#5
|
||||
|
||||
|
Quote:
CPP / C++ / C Code:
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
Recent GIDBlog
2nd Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Knight tour (arrays help needed) | dilmv | CPP / C++ Forum | 7 | 18-Oct-2004 14:31 |
| need help with passing 3 arrays into a function | tommy69 | C Programming Language | 14 | 07-Apr-2004 00:22 |
| Trying to retrieve selective results from a table. | icsys | MySQL / PHP Forum | 9 | 18-Nov-2003 03:31 |
| Search Engine Positioning 101 and 201 "How To" Tips... | 000 | Search Engine Optimization Forum | 0 | 29-May-2003 10:34 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The