you declare and initialise num1 at the beginning. Then on this line:
int num1 = num1 + num2;
You are redeclaring another "num1" that is "shadowing" (hiding) the first one you've declared. At this point the compiler sees the "num1" in the expression as the one you've just declared.
You don't need to declared a new num1, you just need to assign it, so, to fix:
Or, more to the point:
Make sure you read and understand (google for it) variable declaration, scoping and assignment.
indelvarnMember Since 14 Dec 2012
Offline Last Active Dec 14 2012 07:04 AM
- Group Members
- Active Posts 2
- Profile Views 169
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
indelvarn hasn't added any contacts yet.
No latest visitors to show