🔒 Closed 2d array help po

Status
Not open for further replies.
boss hindi ko po talaga kaya ang logic pwede po bang pagawa na lang kahit ngayon lang...please po.
 
ito pano po ba i aline sa grid nya..
#include<iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){

int myArray[2][5] = {{1,2,3,4,5},{6,7,8,9,10}};
int i, j;

cout<<"x "<<" y " << " "<< "x^2 "<<" "<< " y^2 "<<endl;
cout <<"\n";

for(i = 0; i < 5; i++) { //loop for col values


for(j = 0; j < 2; j++) { //loop for row values



cout << myArray[j] << " ";


}
cout << endl; //creates new line after row is created
}
for(i = 0; i < 5; i++) {


for(j = 0; j < 2; j++) {


cout << pow (myArray[j], 2) <<" ";


}
cout << endl;
}

system("PAUSE");
return 0;
}
 
ito pano po ba i aline sa grid nya..
Align sa header? Ilagay mo nalang ang squared values sa array mismo, otherwise use pow and append the values beforehand to the array. Initialize the array as [4][5] para mailagay ang result sa pow. Iwas tayo sa hassle po if di talaga alam gawin..
 
ano po kayang mali dito para makuha iyong xy product?
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(){

int myArray[2][5] = {{1,2,3,4,5},{6,7,8,9,10}};
int product = 1;
cout << " x " << " y " << " " << " x^2 " << " " << " y^2" <<" "<< "xy" <<"\n\n";
for (int i = 0; i < 5; i++) { //loop for col values
for(int j = 0; j < 2; j++) { //loop for row values
cout << setw(2);
cout << myArray[j] << " ";
}
for(int k = 0; k < 2; k++) { //loop for row values
cout << setw(5);
cout << pow (myArray[k], 2) << " ";
}for(int l = 0; l < 2; ++l){

product *= myArray[l];


}

cout << product;
cout << endl;//creates new line after row is created

}

system("PAUSE");
return 0;
}
 
pano ba gawan ng sum of row ito?
kada row ay may summation..please last help na lang po
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(){

int myArray[2][5] = {{1,2,3,4,5},{6,7,8,9,10}};

cout << " x " << " y " << " " << " x^2 " << " "
<< " y^2" <<setw(7)<< "xy" <<"\n\n";

for (int i = 0; i < 5; i++) { //loop for col values
for(int j = 0; j < 2; j++) { //loop for row values
cout << setw(2);
cout << myArray[j] << " ";
}
for(int k = 0; k < 2; k++) { //loop for row values
cout << setw(5);
cout << pow (myArray[k], 2) << " ";

}int product = 1;

for (int l = 0; l < 2; l++) {//loop for col values
cout <<setw(5);
product *= myArray[l];
}
cout << product;
cout << endl;//creates new line after row is created
}

system("PAUSE");
return 0;
}
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 27
    Replies
  • 1K
    Views
  • 4
    Participants
Last reply from:
lemmor

Online now

Members online
338
Guests online
1,081
Total visitors
1,419

Forum statistics

Threads
2,275,084
Posts
28,960,556
Members
1,233,585
Latest member
Natsuuuu77
Back
Top