CS 1711 - Assignment 5

Due: 5 pm, November 23

Question 1

A `histogram' is used to display frequency of occurrence of some object. We are going to create a histogram of the frequency of occurrence of positive integers in the input stream. That is, the user will enter a sequence of positive integers (between 1 and 8) and the program will then produce a histogram with stars to indicate an occurrence. For example, the inputs
1, 3, 4, 7, 1, 8, 4, 6, 7, 7, 3, 3, 2, 2
should produce the output

1   **
2   **
3   ***
4   **
6   *
7   ***
8   *

Your program must use the following functions:

void init_array(int a[], int size);
// initializes the array a[] which counts frequencies of integers

void  fill_array( int a[], int size);
// Pre: a[] is initialized
// Post: a[i] contains the frequency of integer i

void  make_hist(const int a[], int size);
// Pre: a[i] contains the frequency of integer i
// Post: the histogram has been printed to the screen

File name: histog.cpp

Question 2

From the Text: Chapter 10, Programming Project 11.

File name: seats.cpp