#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
  int A[10];
  int sum, largest_index, smallest_index, val;
  bool found;
  char ans;

  cout << "Enter 10 ints: ";

  sum = 0;
  for (int i=0; i<10; i++) {
    cin >> A[i];
    sum += A[i];
  }
  cout << "Sum of values: " << sum << endl;

  largest_index = 0;
  smallest_index = 0;
  for (int i=1; i<10; i++) {
    if (A[i] > A[largest_index])
      largest_index = i;
    if (A[i] < A[smallest_index])
      smallest_index = i;
  }
  cout << "Largest value is " << A[largest_index] << " at element "
       << largest_index << endl;
  cout << "Smallest value is " << A[smallest_index] << " at element "
       << smallest_index << endl;

  do {
    cout << "Search for what value: ";
    cin >> val;
    int i = 0;
    found = false;
    while (i<10 && !found)
      if (A[i] == val)
        found = true;
      else
        i++;

    if (found)
      cout << "Found at index: " << i << endl;
    else
      cout << "Not found" << endl;

    cout << "Another search? ";
    cin >> ans;
  } while (ans == 'y');

  system("pause");
}

//change int array to string
//change to const instead of literal 10

