Respuesta :
Answer:
//include the required packages
#include<iostream>
using namespace std;
//function declarations
void menuFunction();
void sum(int[],int[],int);
void remDiv(int[],int[],int);
//main function
int main(){
//function call to print menu
menuFunction();
}
//menu function
void menuFunction(){
int size,i,ch; //variables declaration
//prompt the user to enter the size of the array
cout<<"Enter the size of the arrays: ";
//read size of the arrays
cin>>size;
//array declarations
int a[size],b[size];
//prompt the user to enter the elements of first array
cout<<"Enter elements of first array:"<<endl;
//iterate a for loop
for (i=0;i<size;i++){
//read elements of first array
cin>>a[i];
}
//prompt the user to enter the elements of second array
cout<<"Enter elements of second array:"<<endl;
//iterate a for loop
for (i=0;i<size;i++){
//read elements of second array
cin>>b[i];
}
//while true
while(1)
{
//display menu
cout<<"1.print the summation\n2.print the remainder of the division"<<endl; cout<<"3.exit\nChoose your option:";
//read option from user
cin>>ch;
//pass option to switch
switch(ch)
{
case 1:
//print sum of the array using function call
sum(a,b,size);
break;
case 2:
//print the reminder of division using function call
remDiv(a,b,size);
break;
case 3:
//exit
exit(0);
break;
case 4:
//if user enter wrong option
cout<<"Choose correct option"<<endl;
}
}
}
//sum function
void sum(int a[],int b[],int size)
{
int i;
//declare third array
int x[size];
//print the statement
cout<<"The summation of two arrays is: ";
//iterate a for loop
for(i=0;i<size;i++)
{
/*calculate sum and store in third array*/
x[i]=a[i]+b[i];
//print third array element
cout<<x[i]<<" ";
}
cout<<endl;
}
//remDiv function
void remDiv(int a[],int b[],int size){
int i;
//declare third array
int x[size];
//print the statement
cout<<"The remainders of two arrays is: ";
//iterate a for loop
for(i=0;i<size;i++)
{
//calculate remainder and store in third array
x[i]=a[i]%b[i];
//print third array element
cout<<x[i]<<" ";
}
cout<<endl;
}