/*
Declare a one-dimensional array of type float and of maximum size 100.
Then ask the user to enter the actual size of the array (the number of
elements that will be used). The read the array. Then ask the usre to 
enter a real number x to search for. Then find how many times x appears in 
the array by using a function.
*/ 
#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++;
		return count;
}
