# LISP - Arithmetic Operators

The following table shows all the arithmetic operators supported by LISP. Assume variable A holds 10 and variable B holds 20 then −

Operator Description Example
+ Adds two operands (+A B) will give 30
- Subtracts second operand from the first (- A B) will give -10
* Multiplies both operands (* A B) will give 200
/ Divides numerator by de-numerator (/ B A) will give 2
mod,rem Modulus Operator and remainder of after an integer division (mod B A )will give 0
incf Increments operator increases integer value by the second argument specified (incf A 3) will give 13
decf Decrements operator decreases integer value by the second argument specified (decf A 4) will give 9

## Example

Create a new source code file named main.lisp and type the following code in it.

```(setq a 10)
(setq b 20)
(format t "~% A + B = ~d" (+ a b))
(format t "~% A - B = ~d" (- a b))
(format t "~% A x B = ~d" (* a b))
(format t "~% B / A = ~d" (/ b a))
(format t "~% Increment A by 3 = ~d" (incf a 3))
(format t "~% Decrement A by 4 = ~d" (decf a 4))
```

When you click the Execute button, or type Ctrl+E, LISP executes it immediately and the result returned is −

```A + B = 30
A - B = -10
A x B = 200
B / A = 2
Increment A by 3 = 13
Decrement A by 4 = 9
```
lisp_operators.htm