#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

// declare const variable for array size, and array prototypes
const int SIZE = 20;
void fill(int arr[SIZE]);
void print(int arr[SIZE]);
void printRanges(int arr[SIZE]);

int main() {

    // create an array with 20 components 
    int arr[SIZE] = { 0 };

    // call functions
    fill(arr);
    print(arr);
    printRanges(arr);



    // pause and exit
    getchar();
    getchar();
    return 0;
}

//fills array arr with 20 random numbers
void fill(int arr[SIZE]) {
    for (int i = 0; i < SIZE; i++) {
        arr[i] = rand() % 100;
    }
}

// prints the array
void print(int arr[SIZE]) {
    for (int i = 0; i < SIZE; i++) {
        cout << arr[i] << " ";
    }
}

// finds the range of each value in the array and stores it in the array ticker, then prints
// a list from 00-90 documenting how many values are in each range
void printRanges(int arr[SIZE]) {
    int ticker[10] = { 0 };

    for (int i = 0; i < SIZE; i++) {
        int index = arr[i] / 10;
        if (index < 10) {
            ticker[index] += 1;
        }
    }
    cout << endl;
    for (int i = 0; i < 10; i++) {
        cout << setfill('0') << setw(2) << i << ": ";
        cout << setfill('*') << setw(ticker[i]) << "" << endl;
    }
}