<p>If i have this fragment of code:</p>
<p>int a;
a = 80;</p>
<p>Is there a way i can assign "a" a different integer later in my code? I've tried just putting:</p>
<p>a = 90;</p>
<p>But the resultant code just adds 80 and 90, it doesn't assign "a" the two different numbers.</p>
<p>Any thoughts?</p>
<p>Are you sure? What’s your code look like? because I just tested that and it came out as 90.</p>
<p>did you use +=?</p>
<p>Because it assigns a new value. That’s the purpose of a variable.</p>
<p>I’m sure! I’ll PM you my code, check your inbox!</p>
<p>Your code would first assign variable a the int value of 80, then assign the same variable with the int value of 90 after removing the initial value of 80, not assign var a with two different variables (I think this is what you actually meant, I’m just clarifying). The += (a += 90) would add 90 to var a.</p>
<p>Pretty sure you used +=. If you actually used a = 90;, then it would reassign the value of a to 90, not add it. That wouldn’t make sense.</p>
<p>Got nothing in my inbox. But given what you showed me, my output was 90.</p>
<p>Thanks guys, I think i need to look over my code some more. I’ll tell you when i spot my problem.</p>
<p>“a” is a lame variable name. Using it twice is also lame</p>
ImBrian
September 25, 2010, 10:46pm
9
<p>The code you posted should assign 90 to a.
Try posting the code in [ code ] [ /code ] tags
(without the spaces between the square brackets)
That way, we can see what you’re doing and the code should keep the formatting (indentations, etc) that you programmed it in.</p>