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 trialRomi Stepovich
8,473 PointsAuto increment the variable named unstable: int unstable = 25; unstable -= 5;
I don't understand what the next number will be. I've tried several numbers. I've looked at the code but nothing is making sense. I thought the next number was 19. Then I thought perhaps the next number was 26. I actually need to see each step to understand how I get to the resolution and the explanations I see which have a bunch of ++s, etc. are not showing me a step-by-step explanation of how I can reach the result.
Romi Stepovich
8,473 PointsI originally thought I just needed to add or subtract to get an answer, but obviously I need to add some code. This is a quiz for operators and expressions. Some of the same code that we did in the lecture before the quiz included these examples:
include <stdio.h>
int main() {
int a = 9;
printf("a %d\n", a);
int c = a++;
printf("c %d a%d\n", c, a);
int d = a--;
printf("d %d a%d\n", d, a);
int b = a % 4;
printf("b %d a%d\n", b, a);
float fa = 5.0 / .5;
printf("fa %f\n", fa);
fa *= 10;
printf("fa %f\n", fa);
return 0;
}
However, when I try to use it to answer the question above, Auto increment the variable named unstable: int unstable = 25; unstable -= 5; I get a wrong answer every time. I don't understand if I am supposed to write something like:
int. unstable = 25++;
or
int. unstable = 5++
or
int. unstable = a++
While all of this made sense in the lecture, applying it with the word unstable seems to be throwing me off.
1 Answer
Romi Stepovich
8,473 PointsActually, I just finally figured it out. It was:
unstable++; unstable--;
I was just overthinking like I always do.
Scott Evans
4,236 PointsScott Evans
4,236 PointsHi Romi,
Could you add which specific bits of code you are struggling to understand, that would allow me to explain more specificlly.
Thanks