You are not logged in. Please login at www.codechef.com to post your questions!

×

# If there is + or -sign in ahead of a variable, then what does it means??

 0 For e.g. c+ asked 13 Jun, 23:18 1●1 accept rate: 0%

 1 Do you mean expressions like c+=5; or c-=5; ? answered 14 Jun, 00:20 4★vbt_95 440●6 accept rate: 27% Yes. I meant that (15 Jun, 08:45) These are short-hand operations. If it's written that c+=(any expression) than that is equivalent to c=c+(expression). It works in a similar way for c-=exp as c=c-exp and other operators. (15 Jun, 14:32) vbt_954★
 1 ah, I see, I saw this question yesterday, and I thought you meant -5, or +5...I am stupid ok right, so usually there are these, for the positive signs first var++, ++var, var += 5 . first and second statement increments the variable by exactly one, meanwhile the thirdstatement increment the variable by how much value you put on the right of the += symbol, I put 5 so, the variable will be incremented by 5. E.g int var = 2; var++; //var becomes 3 ++var; //var becomes 4 var += 5; //var becomes 9  now, after you have seen the example, you might be wondering, what's the difference between ++var and var++, this can be easily explained through a simple example E.g int var = 2; int lol = var++;  the pseudo-code above is the same as int var = 2; int lol = var; var = var + 1;  and int var = 2; int lol = ++var;  which is the same as int var = 2; var = var + 1; int lol = var;  which means, that var++, return the original value, and then increment, while ++var increment first and then return the value, as for var += 1 or var += 2 or anynumber,  is the same as var = var + 1 var = var + 2 var = var + anynumber  now that you understand the positive sign, the negative sign is the exact same, except it decrement answered 15 Jun, 10:02 2★flaze07 153●6 accept rate: 21%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×12

question asked: 13 Jun, 23:18

question was seen: 99 times

last updated: 15 Jun, 14:32