From WikiChip
Difference between revisions of "c/basic arithmetics"
< c

(Created page with "Just about every program is going to need to do some '''basic arithmetics''' - the ability to manipulate values using basic math operations such as addition and subtraction. ...")
(No difference)

Revision as of 16:19, 27 December 2013

Just about every program is going to need to do some basic arithmetics - the ability to manipulate values using basic math operations such as addition and subtraction.

Expressions & Operators

Once a variable has been declared and assigned some value, it is possible to use that variable in various arithmetic operations. Expressions, among other things, is the combination of arithmetic operators, values, and variables, that are combined together to produce a single value.

C provides the following basic arithmetic operators:

Operator Description
+ Addition of both operands
- Subtraction of 2nd operand from 1st
* Multiplication of both operands
/ Division of 1st operand from 2nd
 % Remainder of a division of 1st operand from 2nd