Jump to content

Operators (increment and decrement)

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Sionofdarkness

Sionofdarkness

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 384 posts
How are increment and decrement operators used in loops (that's all I know, they're used in loops). But how are they used in loops, and when are they used? Aren't * and / (multiplication and division) operators too?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
increment and decrement operators are unary (1 operand) whereas +, -, *, / are binary (2 operands). Increment and decrement are used anywhere you want to quickly and efficiently increase/decrease a value by 1. This occurs frequently in for loops, but can happen in a wide range of places, such as counting the occurances of 'a' in the string "A long way away was a cute little kitten."
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
WingedPanther said it perfectly.

#4
Sionofdarkness

Sionofdarkness

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 384 posts
Now that I think about it, I can imagine quite a few scenarios in which that could be used...