Can anyone explain this code to me ----- a+=(a==number) ?
-
Thank you in advance.
-
Answer:
It is possibly python, maybe c because python has taken a lot from c. It is basically trying to make a=a+boolean(True or false value). a==number, returns a boolean. The word "number" in this code is a variable. So basically when they write == you are asking the computer if the two are the same. If a is the same as number it will return true, if not it will return false. += means that a becomes a+ what ever you put on the other side of the =.
Princess Jamela at Yahoo! Answers Visit the source
Other answers
in C there are arithmetic operators and comparison operator. += is an arithmetic operator, x+=5 is the same as x= x+5, this is a legal statement because x+5 is evaluated first, then x+5 is reassigned to x, so if x is 6, x = x+5 will assign the value 11 to x. == is a comparison operator, comparison operators result in a value of 1 if the comparison succeeds or result in the value 0 if the comparison fails, but this result is not usually assigned this way by convention, but C allows it. You would normaly only store a success or failure in a seperate int or boolean variable or maybe even keep track of the number of successes or failures, but the convoluted expression in your example seems to have no purpose. your example of a+=(a==number) is just nerd geek stuff
If a equals number, a is assigned the value of a + 1 (increments the value of a with 1) It not, a is assigned the value of a + 0 (a remains the same value). It could be written like: a = a + (a == number); or even: if (a == number) a = a + 1; // alternatively a += 1 or a++; The latter is the least confusing perhaps. Another alternative could be to use a ternary a = a + (a == number ? 1 : 0);
If this is C or C++ than you are adding 1 to a assuming that a is equal to number and 0 if it's unequal. If this is Java than you're just going to get an error.
It could be written like: a = a + (a==number); reassigning the value of a
Related Q & A:
- Can anyone tell me how to select a University in Aus or NZ to study MA or MS or MBA in Communication?Best solution by Yahoo! Answers
- Can anyone explain this dream to me?Best solution by Yahoo! Answers
- How can I find the address with just a phone number?Best solution by Yahoo! Answers
- Can anyone out there help me find a job?Best solution by totaljobs.com
- Can anyone help with a code for a ford fiesta radio?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.