Thread: incrementing
View Single Post
  #3   Spotlight this post!  
Unread 07-12-2006, 23:09
Ari Allyn-Feuer Ari Allyn-Feuer is offline
Registered User
FRC #0753
 
Join Date: Feb 2006
Location: Bend, OR
Posts: 22
Ari Allyn-Feuer is on a distinguished road
Re: incrementing

Quote:
Originally Posted by teh_pwnerer795
HEy Quick Question

If i say..

static int i = 1;

i++;

Then it will increase by 1..... how do i increase by 2... or maybe 3... would it be?

static int i = 1;

i++2;

... maybe? lol i ono talk to me
You can use the ordinary mathematical operators in C. The syntax is:

name_of_var = [EXPRESSION]

You can string them together:

var1 = var2 = 3

sets both var1 and var2 to 3.

You can use +, -, *, divide, everything. Please note that with integers, divide just truncates. Also, there are a few little things C does. Like ++ adds one without the equals, -- subtracts without it. varname += n will add the value n to varname. same for -=, *=.

Also, you can use the symbol % for remainder in division, or for modular arithmetic. Like 7%3=1, 56%10=6, 39%17=5.

If you need any more help, ask me. ari.allynfeuer@gmail.com

Ari.