Welcome to the Treehouse Community
Looking to learn something new?
Wich is a compact division the Quizz No. 5?
I intented 3 forms of the division learninf from the video and my result is wrong ...
Andrew Pope11,915 Points
Say we had the value 3 assigned to an integer variable called a. Now we want to add 4 on to a. We could do it like this:
int a = 3; a = a + 4; // This is one way to add 4 to the integer variable a.
This is fine, however we can do it slightly differently and make our code more compact.
int a = 3; a += 4; // This is the compact way of doing it.
In C/C++/Objective-C, the basic mathematical operators have their own compact notation, for example.
a += 3; // This is the compact form of a = a + 3 a -= 3; // This is the compact form of a = a - 3 a *= 3; // This is the compact form of a = a * 3
and finally (although I'm sure you have guessed it already!),
a /= 3; // This is the compact form of a = a/3 (So the compact form of division)
Basically, it's a way of saying "Hey, divide a by 3, then make sure that a is set to this new value".
I hope this helps!
I'm newbie in the concepts of C ... and TreeHouse is the best solution for learning in this area, Thanks you very much for the response.and the help.