Broken number 10?

I have literally just started learning C++. Going through and doing semi guided lessons from a book. I ran into an issue within 10mins that I have absolutely no idea how it could be a problem. The console does not like the number 10, not as an integer anyways, here is the code:
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

using namespace std;

int main()
{
    int mynumber;
    mynumber = 10 + 4 - 4;
    cout << mynumber << endl;
    return 0;
}



Super simple stuff, that should come out to 10 in the console, just getting the basics down and trying to remember everything. In the console, this is what it comes out with:


Process returned 1968632969 <0x7556f489> execution time : 0.035 s
Press any key to continue.

I'm using Code::Blocks and the compiler that it came bundled with when I downloaded it from Code::Blocks site. Am I doing something wrong? Any variation on getting the number 10 comes up blank. Any and all insight on the problem is greatly appreciated.
closed account (jwkNwA7f)
This should help: http://www.cplusplus.com/forum/beginner/1988/

Hope this helped!

Edit: The console would just display it for less than a second. The other stuff is C::B related. I had always used cin.get(); before return 0;, which waits for the 'Enter' to be pressed, back when I used the console. There are many ways of fixing it. I think this way is not liked by others, but I am not sure.
Last edited on
It stays up until I tell it to close. But where it should pop up with a 10 in the variable spot, nothing comes up. If I do
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>

using namespace std;

int main()
{
    int mynumber;
    mynumber = 2 + 5;
    cout << mynumber << endl;
    return 0;
}

It comes out normal
7
Process returned 0 <0x0> execution time : 0.106 s
Press any key to continue.

From what I can see, its just the number 10 that will not show up as a value, but will show up as part of a string.
That's not his problem...

Your program appears to be correct. I suspect there is something wrong with either your compiler setup or your project options. You did choose new project, console application, correct?
I did, and gave it a basic name so I knew where to find it. The first project I did had the same issue, thought it might have been something I had done in that particular project. How do I check/change my compiler settings?
I'm not actually at my PC right now, so I can't look it up until I get back late tomorrow evening... Sorry. Mayb someone else can help before then...

I the meantime, google around a Code::Blocks tutorial for first program or something and see if you missed any steps...

Good luck!
Do you have the newest code::blocks? I never had a problem outputting 10.
Compiler setting is at the top under setting->compiler
Topic archived. No new replies allowed.