News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

my output/variables have a problems

Started by LDgaming, February 25, 2014, 04:10:11 AM

Previous topic - Next topic

LDgaming

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

stahta01

#1
This is a programming problem; therefore NOT valid on this site.
Please read the CB Rules and FAQs.

http://forums.next.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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

LDgaming

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?

Jenna

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!