This is my code please tell me if there is a way to do what I listed in the title. Do i need to download and include a class? What do I have to do?
#include <iostream>
using namespace std;
int divide(int arr[],int size){
size=2;
cout<<"Please enter your dividend"<<endl;
cin >>arr[0];
cout<<"Please enter your divisor"<<endl;
cin >>arr[1];
int quotient = arr[0] / arr[1];
int remiander = arr[0] % arr[1];
cout<<quotient<<"R"<<remiander<<endl;
}
int multiply(int arr[], int size){
cout<<"How many numbers do you wish to multiply together?"<<endl;
cin>>size;
cout<<"Enter the base number that is being multiplied"<<endl;
cin>>arr[0];
int product=arr[0];
for(int x=1;x<size;x++){
cout<<"Please enter a number that you wish to muliply by"<<endl;
cin>>arr[x];
product*= arr[x];
}
return product;
}
int add(int arr[], int size) {
int sum = 0 ;
cout<<"How many numbers do you want to add?"<<endl;
cin>>size ;
for(int x=0;x<size;x++){
cout<<"Please enter a number that you wish to have in your sum"<<endl;
cin>>arr[x] ;
sum+=arr[x] ;
}
return sum ;
}
int sub(int arr[], int size){
cout<<"How many numbers do you wish to subtract?"<< endl;
cin>>size;
cout<<"Enter the number you wish to subtract from"<< endl;
cin>>arr[0];
int diff = arr[0];
for(int x=1;x<size;x++){
cout<<"Please enter a number that you would like to subtract"<< endl;
cin>>arr[x];
diff-=arr[x];
}
}
int main(){
int operation = 0;
cout<<"Which operation do you want? Enter 1 for addition, 2 for subtraction, 3 for division, or 4 for multiplication"<<endl;
cin>>operation;
if (operation == 1){
int A[5];
int r = add(A,sizeof A);
cout<<"The sum is "<<r<<endl;}
if (operation == 2){
int A[5];
int r = sub(A,sizeof A);
cout<<"The difference is "<<r<<endl;}
if (operation == 3){
int A[5];
divide(A,sizeof A);}
if (operation == 4){
int A[5];
int r = multiply(A,sizeof A);
cout<<"The product is "<<r<<endl;}
}