// ****************************************************************************
//  Jeff Balsley  10/15/2001
//
//  Assignment #5:5.	Write a program that declares an array of 5 integers.
//  Write a function that prompts the user for a value to initialize the array
//  to.  Initialize the elements of the array to that value.
//
// ****************************************************************************
//  Known Bugs:
//
//
// ****************************************************************************

#include<iostream>
#include<cmath>
using namespace std;

const int SIZE = 5;                // size of the array

void initialize_array(int myArray[], int number);

int main()
{
	int myArray[SIZE];
	int i;
	double number;

	// As long as the user has not entered an integer, do the following
	do {
		cout << "Please enter an integer > ";

		// take the user's input as a double incase they enter a double.
		// we'll check to make sure it's an int however.
		// later we will convert the input to an integer
		cin >> number;
		if (floor(number) != ceil(number)){
			cout << "**** That is not an integer! ****\n";
		}
	} while (floor(number) != ceil(number));

	// convert the input to an integer
	number = (int)number;

	initialize_array(myArray, number);
	
	// print array
	for (i=0; i<SIZE; ++i){
		cout << "myArray[" << i << "] = " << myArray[i] << "\n";
	}

  	return 0;
}

// ******************************************************************
//  This function will take an array and an integer as input.
//  It will return said array after it initialises every element
//  of the array with the given integer
// ******************************************************************
void initialize_array(int myArray[], int number)
{
	int i;
	for (i=0; i<SIZE; ++i){
		myArray[i] = number;
	}
}
