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

Recommended Answers

All 2 Replies

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

It should be like this: #include <iostream>

Post the code you have written so that we can help you with the part(s) you don't understand.

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,sum=0,n=100,j=0;
    clrscr();
    printf("\n\n THE SERIES IS UNDER : \n\n\n");
    i=2;
    while(i<=n)
    {
        sum=sum+i;
        if(i==2)
            printf("%d",i);
        else
            printf(" + %d",i);
        i=i+3;
    }

    printf("\n\n\n THE SUMMATION OF SERIES IS %d",sum);
    printf("\n\n\n");
    i=2;
    while(i<=n)
    {
        sum=sum+i;
        if(i%5==0)
        {
            if(i==5)
                printf("%d",i);
            else
                printf(" + %d",i);
            j=j+i;
        }
        i=i+3;
    }
    printf("\n\n\n THE SUMMATION OF DIVISIBLE 5 IS %d",j);
getch();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.