Project 02
Home ] Up ]

 

CSIS 250-01

Spring 2001

Date Assigned

02/05/2001

Project Number

02

Date Due

02/12/2001

Keeping in line with the first assignment, develop the following functions and the main driver program in C++:

  1. A function to create an array of random size n of random integer values a[0]…a[n-1].  The value of n should be randomly selected from the closed interval [0, 99].  Values for array elements should be selected randomly from the closed interval [1, 20].  The prototype of the function should be:
    void populate (int a [], int &n);
  2. A function to display the array elements.  The prototype of the function should be:
    void display(int a[], int n);
  3. A function to sort the array values in increasing order using the Bubble sort method. The prototype of the function should be:
    void sortBubble(int a[], int n);
  4. A function to get the distinct (unique) values in increasing order. The prototype of the function should be:
    void getDistinct(int a[], int n, int d[], int &m);
  5. A function to get the distinct values in increasing order with their counts. The prototype of the function should be:
    void getDistinctWithCount(int a[],int n,int d[],int c[],int &m);
  6. A function to display distinct values with their counts.  The prototype of the function should be:
    void display(int d[], int c[], int n);
  7. The main driver program to invoke the functions above in proper order.  You could use the following steps in it.

    do the following 2 times
      populate (a, n)
      display (a, n)
      sortBubble (a, n)
      display (a, n)
      getDistinct (a, n, d, m)
      display (d, m)
      getDistinctWithCounts(a, n, d, c, m)
      display (d, c, m)
      end do

 

For each function, supply a description, the algorithm, well-documented source code in C++, and properly labeled output produced by it.

Submit the following items:

  1. Printed source code.
  2. Properly labeled output.
  3. Completed self-evaluation sheet.

 

Self-Evaluation Sheet

Component

Max Score

Your Score

void populate(int a[], int &n);

5

 

void display(int a[], int n);

5

 

void sortBubble(int a[], int n);

5

 

void getDistinct(int a[], int n, int d[], int &m);

5

 

void getDistinctWithCount(int a[],int n,int d[],int c[],int &m)

5

 

void display(int d[], int c[], int n);

5

 

void main (void);

5

 

Total

35