Simple while loop

Hi folks. Completely new to c++ and decided to start with a simple while loop program. It executes without any error messages but nothing is displayed on the console, just a black screen. I am using visual c++ 2008 express. Any help is much appreciated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

using namespace std;

int main ()
{
	int val = 1;
	while (val <= 10);
	{
		cout << "The value of val is " << val << endl;
		val++;
	}
return 0;
}
on line 8, remove ";" after the while loop, you add that only at the end of functions, initializations and stuff, when you use if, while, for and other things like that, you never add it, just like u dont add it at the end of function arguments, basically, you never add ";" at the end of arguments for a code that continues with {}
Last edited on
You have a semi-colon after the while statement. Remove that and your code should work.
Thank you!
closed account (iAk3T05o)
Mine doesn't want to work (using vs 2008). It keeps showing error C2447: '{' :missing function header (old-style formal list?)
@Nathan2222
You don't have a semicolon after int main(), do you?
(You shouldn't.)
closed account (iAk3T05o)
@long double: i realised the problem. Thanks
Topic archived. No new replies allowed.