Sunday, August 2, 2009

C programming equation?

what does this symbol (in c) mean? += and -=





example:


rowSum += data[row][col]





thanks

C programming equation?
The "+=" operator adds the value of the variable on the right to the current value of the variable on the left. The "-=" operator does the same thing, just with subtraction instead of addition.





In the example, if rowSum = 10 and data[row][col] = 14, the command "rowSum += data[row][col]" would make rowSum = 24. Get it?
Reply:rowSum += data[row][col]





is equivalent to:





rowSum = rowSum + data[row][col]





Likewise, rowSum -= data[row][col]





is equivalent to:





rowSum = rowSum - data[row][col]
Reply:+= and -= are called short hand assignment operators.we can give a+=10 instead of a=a+10
Reply:scalar add. It is like saying 2+2 = 4. Instead you are saying 2 += 2; the answer is still 4.





a = 2;


b = 2;





a += b = 4


------------------------ or





a -= b = 0
Reply:Assignment by sum and difference





chcek this out:


http://en.wikipedia.org/wiki/Operators_i...

garden state

No comments:

Post a Comment