What's new

Closed Sum of eachrow in2d array

Status
Not open for further replies.

lemmor

Honorary Poster
Joined
Dec 28, 2011
Posts
632
Reaction
363
Points
235
Age
48
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;
}
 
Wala na yatang papansin sa tanong ko di yata rin kaya ninyo anu pat me forum ng ganito na humihingi ng tulong llimusan pala ng tulong dito...
 
Status
Not open for further replies.

Similar threads

Back
Top