// Mwape Mulenga
#include <iostream>
using namespace std;
int main()
{
int a[6] = {1,2,3,4,5,6}, sum = 0, avg = 0, l = 6, newl;
char letter;
cout << a << endl;
srand(time(NULL));
for (int l = 0; l < 6; l++)
{
cout << "\nThe number for a[" << l << "]!";
a[l] = (rand() %5) + 15;
cout << "\n" << a[l];
}
while(letter != 'Q')
{
cout << "\n[P]osition [R]everse [A]verage [S]earch [Q]uit";
cout << "\nSelect a letter(Q quits the progam): ";
cin >> letter;
switch(letter)
{
case 'P':
cout << "\n[P]osition selected!" << endl;
for(int l = 0; l < 6; l++)
{
cout << "\nThe integer in array a[" <<
l << "] in the postion " << &a[l] << " is " << a[l] << endl;
}
break;
case 'R':
cout << "\n[R]everse selected!" << endl;
for(int l = 5; l >= 0; l--)
{
cout << "\nThe reversed order integer in array a[" <<
l << "] in the postion " << &a[l] << " is " << a[l] << endl;
}
break;
case 'A':
cout << "\n[A]verage selected!" << endl;
for(int l = 0; l < 6; l++)
{
sum = sum + a[l];
}
avg = sum/l;
cout << "The sum is " << sum;
cout << "\nThe avgerage is " << avg;
break;
case 'S':
cout << "\n[S]earch selected!" << endl;
cout << "Enter a number to search in the array: " << endl;
cin >> newl;
for(int l = 0; l < 6; l++)
{
if(newl == a[l])
{
cout << "Value is in array[ " << l
<< " ] in the postion " << &a[l] << endl;
}
}
cout << "Number is not in array" << endl;
break;
case 'Q':
cout << "\n[Q]uit selected!" << endl;
break;
}
}
return 0;
}