Answer:
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
 int a, b, c[20], search, maxi, mini, totalSum = 0;
 char option;
 int * p;
 cout<< "Enter value for a: ";
 cin>> a;
 cout<< "Enter value for b: ";
 cin>> b;
 if (a == 0 || b == 0){
 cout<< "Both values must be greater than zero.";
 } else if(a>b){
 maxi = a;
 mini = b;
 }
else{
 maxi = b;
 mini = a;
 }
 for (int i =0; i < 20; i++){
 c[i] = (rand() % maxi) + mini;
 totalSum += c[i];
 }
 cout << "Please choose an option: 1 , 2, 3 ";
 cin>> option;
 option = tolower(option);
 switch(option){
 case 1:
 cout << "The Average of the array items is: "<< totalSum/20;
 break;
 case 2:
 cout<< "The sum of the array items is: "<< totalSum;
 break;
 case 3:
 cout<< "Enter number to be searched: ";
 cin>> search;
 p = find (c, c+20, search);
 if (p != c+20)
{
 cout << "Element found in c array: " << *p << '\\';
 }else{
 cout << "Element not found in c array\\";
 }
 break;
 }
}
Step-by-step explanation:
The C++ source code prompts the user for the a,b, option and search values and executes either of the options from the switch statement. Is correct
Step-by-step explanation:
Great work person above me! :)