🔒 Closed Sum of eachrow in2d array

Status
Not open for further replies.

lemmor

Honorary Poster
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.

About this Thread

  • 1
    Replies
  • 484
    Views
  • 1
    Participants
Last reply from:
lemmor

Trending Topics

Online now

Members online
1,248
Guests online
8,489
Total visitors
9,737

Forum statistics

Threads
2,329,343
Posts
29,247,746
Members
1,156,388
Latest member
tastyy
Back
Top