Questions tagged [decrement]

Subtracting one from the value of a variable, generally with the use of an decrement operator.

Subtracting one from the value of a variable, generally with the use of an decrement operator(--).

425 questions
-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.…
-7
votes
4 answers

Why 2 and -2 instead of 1 and -1?

I wrote this very simple program: #include using namespace std; int main() { int x = 0; cout << x++<
AmirRazoR
  • 146
  • 1
  • 9
-9
votes
5 answers

Why this code is not looping (while)?

int main() { int i=3; while(i--) cout << i << " "; system("pause"); return 0; } Result: 2 1 0 Why not: 2 1 0 -1 -2 -3 ...(loop)?
-11
votes
7 answers

C# help declaring variable i initialize it to

I'd like to declare an int variable i, initialize it to 4 and then test the following increment and decrement statements. Comment on the obtained output. Here is the incomplete code that I made: class Program { static void…
Josh
  • 29
  • 1
  • 8
1 2 3
28
29