hi
i am new here and i registered because i couldn't find the answer in google search
my problem is that i could not find max and min of two arrays and the average too
#include<iostream>
using namespace std;
int array1[]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int array2[]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int a;
int print_menu()
{
int choice;
cout<<"#----------------------------------\n";
cout<<"# Manipulation of arrays #\n";
cout<<"# #\n";
cout<<"# BY MAFD #\n";
cout<<"#----------------------------------\n";
cout<<"# 1. Read Array 1 #\n# 2. Read Array 2 #\n";
cout<<"# 3. Max_min_two_arrays #\n# 4. sum_two_arrays #\n";
cout<<"# 5. Average_two_arrays #\n# 6. Quit #\n";
cout<<"#----------------------------------\n";
cout<<"# Enter your Choice (1-6) :";
cin>>choice;
return choice;
}
void print_array(int[],int)
{int number;
cout<<"\nInitialization Of Array "<<a<<endl;
for (int i=1 ; i<=10 ; i++){
cout<<"Enter integer "<<i<<" : ";
cin>>number;
array1[i]= number;}
}
void read_array(int[],int)
{cout<<"\n\nContent of array "<<a<<" : ";
for (int i=1 ; i<=10 ; i++)
cout<<array1[i]<<" ";
cout<<"\n-------------------------\n";
}
void max_min_two_arrays(int[],int[])
{
int max=array1[0];
int min=array1[0];
cout<<"\n\nContent of array 1 : \n";
cout<<array1<<endl;
for (int i=1 ; i<=10 ; i++)
{if (array1[i]>max)
{
max=array1[i];
}
else if (array1[i]<min)
{
min=array1[i];
}
}
}
int main(){
int choice;
do{
system("cls");
choice = print_menu();
switch (choice){
case 1 :
a=1;
print_array(array1,1);
read_array(array1,1);
break;
case 2 :
a=2;
print_array(array2,2);
read_array(array2,2);
break;
case 3 :
max_min_two_arrays;
break;
case 6 :
cout<<"\nThanks and by... MAFD\n"<<endl;
break;
default:
cout<<"*** Error: The choice must be 1 to 6 \n";
}
system("pause");
}
while(choice!=6);
return 0;
}