/*
The following program declares a one-dimensional array of size 100, then 
it reads the size of the array (the number of elements that will be used), 
then it reads the array, then it reads a number to search the array 
for, and then with the help of a function called f, it finds how many 
times the number appears in the array. Also, it displays the array. 
*/
#include <iostream>
using namespace std;
int f(const float[], int n, float);
int main()
{
	int i, n, count;
	float  a[100], x;
	cout << "Enter the actual size: ";
	cin >> n;
	if (n <= 100)
	{
		cout << "Enter the array: ";
		for (i=0; i < n; i++)
			cin >> a[i];
		cout << "Enter a number to search for: ";
		cin >> x;
		count = f(a,n,x);
		cout << count << endl;
		cout << "The array is: " << endl;
		for (i=0; i < n; i++)
			cout << a[i] << '\t';
		cout << endl;
	}
	else
		cout << "Invalid input: size must be < 101.\n";
	return 0;
}

int f(const float b[], int n, float x)
{
		int i, count = 0;
		for (i = 0; i < n; i++)
			if (b[i] == x)
				count++;
		//b[0] = 100;
		return count;
}
