Questions tagged [post-increment]

For issues relating to defining or performing post increment operations.

Post-increment operators increase the value of their operand by 1 (or another specified amount), but the value of the operand in the expression is the operand's original value prior to the increment operation.

561 questions
-7
votes
1 answer

Why can't variables be declared and modified at once? (C++)

Why is this valid: int main() { double good; good++; return 0; } but this is not: int main() { double good++; return 0; } I know that normally you want to initialize variables to some value before increment it (because then it'd just contain…
Futuza
  • 144
  • 8
-7
votes
1 answer

Pre and Post Increment and Decrement in Java

Day after tomorrow is my exam for Computers (JAVA) and I have a big problem in the above title. I understood what does post and pre increment and decrement means. But I can no understand what to do when the matter comes to a complex, long statement.…
-9
votes
1 answer

I'm having trouble understanding how Post Increment (++), Pre Increment work together in an example

I'm having trouble understanding how Post Increment (++), Pre Increment work together in an example. x++ means add 1 to the variable But I am confused with this example: using namespace std; / run this program using the console pauser or add your…
-13
votes
2 answers

post increment and pre increment operator

Please explain me the outcome of this code. //code a when I run this code on my laptop, value of y is 4. And I think, logically value of y should be 5 because by doing x++ it should return 2 without incrementing as it is post increment and then when…
-29
votes
5 answers

Why does integer++ not increment integer value?

Why does num1++ not increment in the printf()? int num1 = 1; printf("num1=%d", num1++); Why does this print num1=1 instead of num1=2?
4thSpace
  • 43,672
  • 97
  • 296
  • 475
1 2 3
37
38