//file: array.cpp
#include <iostream>
using namespace std;
using std::cin;
using std::cout;

typedef double* ArPtr;

void read(double a[], int length);
int search(double a[], int length, double value);

int main()
{ 
  int length;
  cout << "Enter length of array: ";
  cin >> length;
  ArPtr a;
  a = new double[length];

  read(a, length);
  double value;
  cout << "Enter value to search for: ";
  cin >> value;
  int index = search(a, length, value);
  if(index == -1)
     cout << "Sorry! " << value << " was not found in the array.\n";
  else
     cout << value << " is index " << index << " in the array.\n";

  return 0;
}

//fill array with values, using <iostream>
void read(double a[], int length)
{
	cout << "Enter " << length << " values:\n";
	for(int i=0; i < length; i++)
		cin >> a[i];
}//end fillArray


int search(double a[], int length, double value)
{ 
	int i = 0;
	while((a[i] != value) && (i < length))
		i++;
	if(i == length) //value not found in array
		i = -1;
	return i;
	
}//end search


