Code::Blocks Forums
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
As usual while waiting for the next release - don't forget to check the
nightly builds
in the forum.
Home
Help
Search
Login
Register
Code::Blocks Forums
»
User forums
»
Help
»
Getting the wrong result for int var x
« previous
next »
Send this topic
Print
Pages: [
1
]
Go Down
Author
Topic: Getting the wrong result for int var x (Read 3506 times)
Innovative101
Single posting newcomer
Posts: 2
Getting the wrong result for int var x
«
on:
March 19, 2010, 12:42:09 am »
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;
}
Logged
Seronis
Almost regular
Posts: 197
Re: Getting the wrong result for int var x
«
Reply #1 on:
March 19, 2010, 01:30:46 am »
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)
Logged
Jenna
Administrator
Lives here!
Posts: 7252
Re: Getting the wrong result for int var x
«
Reply #2 on:
March 19, 2010, 08:40:14 am »
Unrelated to C::B, thius violating our forum rules.
Topic locked !
Logged
Send this topic
Print
Pages: [
1
]
Go Up
« previous
next »
Code::Blocks Forums
»
User forums
»
Help
»
Getting the wrong result for int var x