Answer to Question #196162 in C++ for hillary

Question #196162

Write a program to add data from two arrays of 2X2 dimension. The arrays must be of double type to process students scores. After addition the program calculates the average of scores from each array. Then the averages are added to get the total of the averages


1
Expert's answer
2021-05-20T18:20:41-0400
#include <iostream>
 
using namespace std;
 
int main()
{
	double A[2][2];
	double B[2][2];
	double sum, aver1, aver2;
	sum = 0;
	cout << "Enter values for first array (2 3 4 5): ";
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			cin >> A[i][j];
			sum += A[i][j];
		}
	}
	aver1 = sum / 4;
	sum = 0;
	cout << "Enter values for second array (2 3 4 5): ";
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			cin >> B[i][j];
			sum += B[i][j];
		}
	}
	aver2 = sum / 4;
	cout << "Average of first array is: " << aver1 << endl;
	cout << "Average of second array is: " << aver2 << endl;
	cout << "Total of averages is: " << aver1 + aver2 << endl;
	system("pause");
	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