- Joined
- 5/8/06
- Messages
- 80
- Points
- 16
How should I write this code so that it takes integers and outputs real numbers? The code below gives me values in integers. For example, 1/4 outputs 0.
Code:
int main()
{
int i, j, nmat;
double **a;
nmat = 5;
Init_Matrix(a, nmat);
for (i = 0; i<nmat; ++i) {
for (j=0; j<nmat; ++j) {
if (i==j) a[i][i] = 18;
if (i!=j) a[i][j] = abs(i-j)/(i+j+2);
cout << "Out " << a[i][j] << " " << " i " << i << " " << " j " << j << "\n";
cout << "te " << (i-j)/(i+j+2);
cout << "\n";
}
}