I'm very new to C++ and have just started out. I'm doing a simple exercise where I need to declare a variable with type int and add to it.
Essentially the integer has a starting value of 44 and I have no idea why.
The exercise comes out of a book I'm following.
Here is my code:
#include <iostream>
using namespace std;
int main()
{
int sum;
sum = sum + 1;
cout << sum;
return 0;
}
If I run the following code I get the answer of 45, which makes no sense at all to me.
I want to understand why sum has a value of 44, if no value is assigned to it.
I'm using VScode and the g++ compiler.
Thanks!