Math

The Assignment Operator, =

  1. The = sign is used to assign value to a variable
  2. On the right side of = can be numbers, other variables, and mathematical operators.
    Example:
    x = y + 12 - z;
    

Mathematical Operators

  1. The following are used in C:
    + addition
    - subtraction
    * multiplication
    / division
    % remainder

  2. If multiple operators are used in one expression, the following rules are applied:

Some Math Library Functions

Function Library Description
abs(x) stdlib.h Returns the absolute value of its integer argument.
fabs(x) math.h Returns the absolute value of its floating point (double, etc.) argument.
cos(x) math.h Returns the cosine(x) where x is in radians.
sin(x) math.h Returns the sine(x) where x is in radians.
tan(x) math.h Returns the tangent(x) where x is in radians.
exp(x) math.h Returns e raised to x
log(x) math.h Returns the natural logarithm of x
log10(x) math.h Returns the base-10 logarithm of x
pow(x,y) math.h Returns x raised to y. If x is negative, y must be a whole number.
sqrt(x) math.h Returns the non-negative square root of x.
ceil(x) math.h Returns the smallest integer not less than x.
floor(x) math.h Returns the largest whole number not greater than x.