🔒 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
  • 487
    Views
  • 1
    Participants
Last reply from:
lemmor

Online now

Members online
1,033
Guests online
5,166
Total visitors
6,199

Forum statistics

Threads
2,349,780
Posts
29,364,307
Members
1,089,328
Latest member
reca111
Back
Top