If-Else Statement not working correctly

Hello

So recently I got back into programming with C++ in Visual Studio 2013 Express. I am just a beginner, so I searched up some easy exercises and started playing around with if-else statements.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

using namespace std;

int main()
{
	int score;

	cout << "Please enter your score.\n";
	cin >> score;

	if(score >= 100)
	{
		cout << "HIGH\n";
		cout << "Press enter to continue\n";
	}
	else
	{
		cout << "LOW\n";
		cout << "Press enter to continue\n";
	}

	cin.get();

	return 0;
}


For some reason, when I use the debug tool to run the program, it ends the program whenever I enter the score. Any input is greatly appreciated.
When I built it. it worked perfectly. make sure you are "running it right"
Yeah, I just hit F5 but for some reason it doesn't work the way I want it too in Visual Studio.
when I use the debug tool to run the program, it ends the program whenever I enter the score
Debug run does not keep window opened after program finishes. It is ntended to find errors in program and if program finished, there is no need to keep it open anymore.

Either place a breakpoint at closing brace of main, or run without debugging.
Ok, I thought the cin.get(); line would make the program wait for me to press enter, then it would end. Sorry if I act like a nob, its because I am one.
I thought the cin.get(); line would make the program wait for me to press enter
It might. Or might not. Depending on state of input buffer.
In your case there is an unread character here (newline — operator>> does not extract whitespace characters after actual value).
Ok, thanks. So how would one go about running it without the debugger? Thanks for the help so far.
Debug → Start without debugging or Ctrl + F5
Ok, that still gave me the same problem. Would you mind enlightening me on the reason why cin.get() is not working?
Make sure that you are linking it to console subsystem: http://stackoverflow.com/a/1152873
Ok, that made it work. This was my first time using this forum and it was a big help. Thanks again all.
Topic archived. No new replies allowed.