Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Andrew Thompson
Courses Plus Student 177 PointsAuto increment a int type variable .
Given :
int var_1 =14; var_1 -= 2;
How to auto increment var_1: var_1++;
1 Answer
Robert Goddard
15,019 PointsI'm not sure I completely understand your question.
This assigns var_1 to 14.
int var_1 = 14;
This negates 2 from var_1
var_1 -= 2;
To increment var_1 by 1 you can do:
var_1++;