Author Topic: my output/variables have a problems  (Read 3453 times)

Offline LDgaming

  • Single posting newcomer
  • *
  • Posts: 2
my output/variables have a problems
« on: February 25, 2014, 04:10:11 am »
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?

#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";
        }
    }
}

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7785
    • My Best Post
Re: my output/variables have a problems
« Reply #1 on: February 25, 2014, 04:28:45 am »
This is a programming problem; therefore NOT valid on this site.
Please read the CB Rules and FAQs.

http://forums.codeblocks.org/index.php/topic,9996.0.html
http://wiki.codeblocks.org/index.php?title=FAQ
If you think it is a Compiler problem please read on follow this link http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

I suggest turning up the Compiler Warnings.

If you tell us the compiler we might be able to tell you how to turn up the warnings.

Tim S.
« Last Edit: February 25, 2014, 04:30:38 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline LDgaming

  • Single posting newcomer
  • *
  • Posts: 2
Re: my output/variables have a problems
« Reply #2 on: February 25, 2014, 05:59:05 am »
I think you miss understand me. My programs work. I had proper outputs, but today when I tried to run any of my programs none of the outputs were properly working. Regardless of which program I tried to use. I can't even compile the hello world program.

How is this a programming problem if the program worked before but now I'm getting garbage out?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: my output/variables have a problems
« Reply #3 on: February 25, 2014, 06:27:48 am »
First:
always use code-tags (the little # in the forums-editor), if you post code.

Second it's definitely a programming issue, at least if you used copy and paste for your code.
By the way, it does not even compile here, but even if this is fixed, there is a simple error in one of your loops.
I think you find it yourself if you double-check them again.

Third: as Tim states that post violates our forum rules.
Please (re-)read them.
When registering here, you accepted to follow these rules, so please do so.
Thank you!