#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

dayotnPosts: 0Member
edited April 8

Please help. I have an programming assignment due and i can't figure out how to code it.

Complete the following code so that the program: 1. reads in any number of values in a given range into an array of integers 2. counts the frequency of each value, storing the results in a second array of integers 3. displays the results as the indices and frequencies of the second array */

include (iostream) --- wont let me do the less than sign

include (array)

using namespace std;

// Global constants const int ARRAY_SIZE = 1000; const int RANGE_SIZE = 100;

int main() { // TO DO: declare two arrays: // 1. the array of integer values of size ARRAY_SIZE // 2. the array of frequencies (integers) of // size RANGE_SIZE

// TO DO: declare an integer variable for the # of values // entered into the value array

// TO DO: read in user input into the value array, until either: // 1. the user has entered a value outside // the range {0, ..., RANGE_SIZE-1}, or // 2. the value array is full (ARRAY_SIZE values have been // entered by the user).

// TO DO: go through the value array, and for each value, // increment its frequency in the frequency array // HINT: for the value i, its element in the frequency array // can be found at index i (0 <= i < RANGE_SIZE)

// TO DO: go through the frequency array, and display each // value (index) and the corresponding frequency // NOTE: only show value/frequency pairs for frequencies > 0 //

/* 25 points EXTRA CREDIT: display the value/frequency pairs in order of decreasing frequency For 20 points additional extra credit, modify/update (a copy of) your program so that it works for any range of numbers (not just 0 ... RANGE_SIZE-1). For 10 points additional extra credit, modify/update (a copy of) your program so that defines and uses function templates to: read in user input into the value array calculate the frequency for each value into the frequency array display the values and their respective frequencies

*/

// done return 0; } // end main

Assignment posted above. The main program would be much appreciated, or just any help with it or the extra credits. Thank you so much