Since I am new to these forums, forgive me if I have posted this in the wrong place.
Enough of the chit-chat.
Well, the problem is that I was practicing on special operators such +=, -=, *=, /= and %=.
I tried using this code, as well as some additional comments to aid me:
- Code: Select all
include "stdafx.h" // include only this for Microsoft Visual C++ compilers!!
#include <iostream> // blue words are known as 'keywords'.
using namespace std; // 'namespace' is a package which is found in the file 'iostream'.
int main() // 'int' is a function . 'main' is a function name.
{
signed long int j;
j += 1; // '+=' will take whatever is on the left plus whatever is on the right, and then set that number to whatever is on the left. For instance, i += 2 means i = i+2.
cout << j << endl;
j -= 1; // '-=' will take whatever is on the left minus whatever is on the right, and then set that number to whatever is on the left. For instance, i -= 2 means i = i-2.
cout << j << endl;
j *= 1; // '*=' will take whatever is on the left multiply whatever is on the right, and then set that number to whatever is on the left. For instance, i *= 2 means i = i*2.
cout << j << endl;
j /= 1; // '/=' will take whatever is on the left divide by whatever is on the right, and then set that number to whatever is on the left. For instance, i /= 2 means i = i/2.
cout << j << endl;
j %= 1;
cout << j << endl;
cin.get(); // waits until the user presses enter.
return 0; // indicates 'over'. Goes back to the computer and exits the application compiled.
}
This code was successfully compiled. However, when the program was opened, there was a Visual C++ Run-Time error indicating that the variable 'j' was used without being initialized, or something along those lines, and it asked me if I would like to break or continue the program. If I chose continue, the program would hang and I had to end its process. If I chose break, the program would simply hang for a moment before quitting by itself.
What is the error?
