Given the floating point array x[10][10] with initial values,
find the sum of all
• The square of the numbers in the even rows (i.e., rows 2,4,6,8,10)
• The square root of the numbers in the odd(ie column 1,3,5,7,9)
below are the code i've manage so far...
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float x[10][10] = {{1,2,3,4,5,6,7,8,9,0},{13,14,18,19,8,5,6,3,4,2},{8,7,6,4,1,2,3,5,2,8},{11,12,13,14,15,16,17,18,19,20},{-5,-7,-66,-38,7,1,9,44,6,-2},{0,4,7,-3,6,1,8,-3,6,8},{-1,2,-3,4,-5,6,-7,-8,-9,10},{56,9,0,0,3,5,1,-4,-6,3},{2,1,5,-7,4,-6,3,9,0,5},{2,5,67,4,7,8,1,-7,0,6}};
float ev[5][10];
float od[10][5];
int y = 0;
float z = 0;
cout << "For the data inside the program.\n";
for(int i=0; i<10; i++)
{for(int j=0; j<10; j++)
cout << x[i][j] << " ";
}
for (int i = 0; i < 10; i+=2)
{for (int j = 0; j < 10; j++)
{y = pow(x[i][j],2);
ev[5][10] = y;
// dunno how to continue
}
}
cout << "The square of the even row = " << sum_ev
;
for (int j = 0; j < 10; j+=2)
{for (int i = 0; i < 10; i++)
{z = sqrt(x[i][j]);
od[5][10] = z;
// dunno how to continue
}
}
cout << "The square root of the odd column= " << sum_od ;