c:arithmetic_operators

This shows you the differences between two versions of the page.

— |
c:arithmetic_operators [2013/04/04 13:01] (current) 94.222.251.147 created |
||
---|---|---|---|

Line 1: | Line 1: | ||

+ | ====== arithmetic operators ====== | ||

+ | |||

+ | * (multiplicator) \\ | ||

+ | / (dividing) \\ | ||

+ | % (modulo) ... e.g. rest of a number\\ | ||

+ | + -\\ | ||

+ | ++ --\\ | ||

+ | |||

+ | ==== example ==== | ||

+ | <code c> | ||

+ | #include <stdio.h> | ||

+ | |||

+ | int main (void) { | ||

+ | int x,y; | ||

+ | x=2; | ||

+ | |||

+ | x = x+1; // = 3 | ||

+ | x = x++; // = 3 | ||

+ | x = ++x; // = 3 | ||

+ | x = +=x; // = 4 | ||

+ | // and so on | ||

+ | |||

+ | /* | ||

+ | for the wired case of | ||

+ | x = x+++x; | ||

+ | or | ||

+ | x=x---x; | ||

+ | |||

+ | that means | ||

+ | x = x++ +x; | ||

+ | and | ||

+ | x = x-- -x; | ||

+ | |||

+ | |||

+ | also possible is | ||

+ | |||

+ | x = x- --x; | ||

+ | */ | ||

+ | } | ||

+ | |||

+ | </code> | ||

+ | |||

advertising

c/arithmetic_operators.txt · Last modified: 2013/04/04 13:01 by 94.222.251.147

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported