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>
usingnamespace 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 {}