Answer to Question #245641 in C++ for xtian

Question #245641

Question: program that will create 2 one-dimensional arrays then performs multiplication of integers entered into the array. Find the sum of all integers in Array 1, Array 2 and the sum of all products. The number of integers to be entered shall be determined by the user.


1
Expert's answer
2021-10-02T07:24:27-0400
#include <iostream>


using namespace std;




int main(){
	//create 2 one-dimensional arrays then performs multiplication of integers entered into the array. 
	int Array1[100];
	int Array2[100];
	int number;
	//The number of integers to be entered shall be determined by the user.
	cout<<"Enter a number of integers: ";
	cin>>number;
	for(int i=0;i<number;i++){
		cout<<"Enter integer value "<<(i+1)<<" for Array1: ";
		cin>>Array1[i];
		cout<<"Enter integer value "<<(i+1)<<" for Array2: ";
		cin>>Array2[i];
	}
	//Find the sum of all integers in Array 1, Array 2 and the sum of all products. 
	int sumArray1=0;
	int sumArray2=0;
	int productArray1=1;
	int productArray2=1;
	for(int i=0;i<number;i++){
		sumArray1+=Array1[i];
		sumArray2+=Array2[i];
		productArray1*=Array1[i];
		productArray2*=Array2[i];
	}
	cout<<"The sum of all integers in Array 1: "<<sumArray1<<"\n";
	cout<<"The sum of all integers in Array 2: "<<sumArray2<<"\n";
	cout<<"The sum of all integers in Array 1 and Array 2: "<<(sumArray1+sumArray2)<<"\n";
	cout<<"The sum of all products: "<<(productArray1+productArray2)<<"\n";
	 
	cin>>productArray2;
	return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS