Sample Qustion 11
Write a C++ program to add given 2 arrays.
int arr1[3][2]={{12,45},{21,89},{20,9}}
int arr2[3][2]={{20,15},{30,10},{4,7}}
#include <iostream>
using namespace std;
int main()
{
int a[3][2]={{14,15},{21,89},{20,9}};
int b[3][2]={{20,15},{30,10},{4,7}};
int sum [3][2];
int r =3;
int c = 2;
for(int i = 0; i < r; ++i)
for(int j = 0; j < c; ++j)
{
sum[i][j] = a[i][j] + b[i][j];
}
cout << endl << "Sum of two matrix is: " << endl;
for(int i = 0; i < r; ++i)
for(int j = 0; j < c; ++j)
{
cout << sum[i][j] << " ";
if(j == c - 1)
cout << endl;
}
return 0;
}
download file cpp file
do you have any qustion please comment
click the advertisement to help for me ....
int arr1[3][2]={{12,45},{21,89},{20,9}}
int arr2[3][2]={{20,15},{30,10},{4,7}}
#include <iostream>
using namespace std;
int main()
{
int a[3][2]={{14,15},{21,89},{20,9}};
int b[3][2]={{20,15},{30,10},{4,7}};
int sum [3][2];
int r =3;
int c = 2;
for(int i = 0; i < r; ++i)
for(int j = 0; j < c; ++j)
{
sum[i][j] = a[i][j] + b[i][j];
}
cout << endl << "Sum of two matrix is: " << endl;
for(int i = 0; i < r; ++i)
for(int j = 0; j < c; ++j)
{
cout << sum[i][j] << " ";
if(j == c - 1)
cout << endl;
}
return 0;
}
download file cpp file
do you have any qustion please comment
click the advertisement to help for me ....
Comments
Post a Comment