Variables having improper outputs

I keep having an issue with my variables.

For example I have the following code (see below). But the output isn't correct. The output was correct a week ago when I finished it but now its out putting things like 1 * 2 is 747808. This problem is spilling over to all of my other programs.

How can I fix this?

[code]
#include <iostream>

using namespace std;

int main()
{
int i = 0;
int j = 0;
int array[8][8];

for ( int i = 0; i < 8; i++ )
{
for ( int j = 0; i < 8; i++)
{
array[j] = i * j;
}
}
cout << "multiplication table:\n";
for ( int i = 0; i < 8; i++ )
{
for ( int j = 0; j < 8; j++ )
{
cout << " [ " << i <<" ][ " << j << " ] = ";
cout << array[ i ][ j ] << " ";
cout << "\n";
}
}
}
[\code]
You messed up the code tags; your closing tag needs a / instead of a \

An issue I see is that in your first nested for loop that is meant to go through j, you actually check i's value and increment i instead of j.
Topic archived. No new replies allowed.