News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Getting the wrong result for int var x

Started by Innovative101, March 19, 2010, 12:42:09 AM

Previous topic - Next topic

Innovative101

getting result of 5050 console output instead of 1 to 100 Why?
#include <iostream>

using namespace std;

int main()
{
    int x = 0;
    int i;

    for (i = 1; i <= 100; i++)
    {
       x += i;
    }

    cout << x << endl;
    return 0;
}

Seronis

Because thats what your program is designed to do.  See other thread and dont bother replying until you have a question related to the IDE.  Not to your compiler (which you never stated which one you are using, or your OS version, or anything)

Jenna

Unrelated to C::B, thius violating our forum rules.

Topic locked !