inexplicable problem...!!

the output of this code is 1.3 E-34 1.4E-35 ... WHY?¿!!

#include <fstream>
#include <iostream>
using namespace std;

#define n 5
#define m 5
float tx[n][m];
int i,j;

int main()
{
for (i=1;i<n;i++)
for (j=1;j<m;j++){

if (j == 1)
{ //top
tx[i][j]= 5;
}
else
{
if (i == n)
{
tx[i][j]= 4;
}
else
{
if (j == m)
{ //bottom
tx[i][j]= 3;
}
else
{
if (i == 1)
{//left

tx[i][j]= 2;
}
else
{
tx[i][j]= 1;

}
}
}
}
}

for (i=1;i<n;i++)
cout << "\n";
for (j=1;j<m;j++){ //vemos matriz t
cout << tx[i][j];

}

system ("pause");
return 0;

}

Any idea!!?¿
I have not looked through all your code because in the very beginning of your program the statement

if (i == n)

arises the question when variable i can be equal to n if the loop is set as follows

for (i=1;i<n;i++)

And take into account that array indexes are counted starting from 0.
Last edited on
Topic archived. No new replies allowed.