pano po ba ang pag susum ng row isa isa using 2d array
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(){
int myArray[2][5] = {{1,2,3,4,5},{11,12,13,14,15}};
int i,j,k,l;
int sum = 0;
cout << setw(7) << " x "
<< setw(7) << " y "
<< setw(7) << "x^2"
<< setw(7) << "y^2"
<< setw(6) << "xy"<<"\n\n";
for (i = 0; i < 5; i++) { //loop for col values
for (j = 0; j < 2; j++) { //loop for row values
cout << setw(6);
cout << myArray[j] << " ";
}
for(k = 0; k < 2; k++) { //loop for row x^2 and y^2 values
cout << setw(6);
cout << pow (myArray[k], 2) << " ";
}
int product = 1;
for (l = 0; l < 2; l++) {//loop for rows xy values
cout <<setw(6);
product *= myArray[l];
}
cout << product;
cout << endl;//creates new line after row is created
}
system("PAUSE");
return 0;
}
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(){
int myArray[2][5] = {{1,2,3,4,5},{11,12,13,14,15}};
int i,j,k,l;
int sum = 0;
cout << setw(7) << " x "
<< setw(7) << " y "
<< setw(7) << "x^2"
<< setw(7) << "y^2"
<< setw(6) << "xy"<<"\n\n";
for (i = 0; i < 5; i++) { //loop for col values
for (j = 0; j < 2; j++) { //loop for row values
cout << setw(6);
cout << myArray[j] << " ";
}
for(k = 0; k < 2; k++) { //loop for row x^2 and y^2 values
cout << setw(6);
cout << pow (myArray[k], 2) << " ";
}
int product = 1;
for (l = 0; l < 2; l++) {//loop for rows xy values
cout <<setw(6);
product *= myArray[l];
}
cout << product;
cout << endl;//creates new line after row is created
}
system("PAUSE");
return 0;
}