Am using 'Code Blocks' 10.05 on a windows 7 pc to follow the cplusplus language tutorial. Entered the second project 'operating with variables' exactly as written but it won't run. I am not sure why but here it is:
//Operating with variables
#include <iostream>
using namespace std;
int main ()
{
//declaring variables
int a, b;
//process or operation/algorithm
a = 5;
b = 2;
a = a + 1;
result = a - b;
//print out the result:
cout << result;
//end the program
return 0;
}
When I run it, line 12 shows:
error: 'result' was not declared in this scope
I'm not sure what this means or how to fix it? Any help is greatly appreciated. Thanks!
OK-Sorry about the tags. I went back over the lesson in the tutorial and it looks like the author says that 'result = a - b;' is declaring result. How else would I declare it other than the manner listed in the tutorial? Thanks!
// operating with variables
#include <iostream>
usingnamespace std;
int main ()
{
// declaring variables:
int a, b;
int result;
// process:
a = 5;
b = 2;
a = a + 1;
result = a - b;
// print out the result:
cout << result;
// terminate the program:
return 0;
}