90 182
Assignments Done
99.5%
Successfully Done
In September 2020

# Answer to Question #32220 in C++ for amin

Question #32220
I wrote a program to descrite a domain (1*1) to i*i cells. (i cells per edge). I want to write two arrays x[i][i] and y[i][i] for (x,y) of centers of cells. The origin is on the south west of the domain, but the program assign 0 to all of x and y array. what is the problem??????????????

for (int m=0; m&lt;i; m++){
for(int n=0; n&lt;i; n++){
x[m][n]=(2*m+1)/(2*i);
y[m][n]=(2*n+1)/(2*i);
}
}
1
2013-06-24T09:23:39-0400
#include <iostream>
using namespace std;

int main() {
int i = 10;
double x[10][10], y[10][10];
//the problem is that you have division int on int.
// you have transfer int into double in one of terms

for (int m=0; m < i; m++){
for(int n=0; n < i; n++){
x[m][n]=double(2*m+1)/(2*i);
y[m][n]=double(2*n+1)/(2*i);
}
}
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!