## Arithmetic tag tutorial

The arithmetic tag looks like this:

[:arithmetic:{*1st operand*}:*operator*:{*2nd operand*}:]

You can use the following operators: + - * / %

**+**is for addition**-**is for subtraction*****is for multiplication**/**is for division**%**is the modulo operator, which gives the remainder of a division operation (the modulus); one use for this is to tell if a number is evenly divisible by a certain number

Usage Example: **[:arithmetic:{2}:+:{3}:]** will show up in the Score Script output as **5**.

The operands can include other Score Script tags.

Usage Example: **[:arithmetic:{[:info:1:user_response:]}:*:{2}:] **will multiply a number the website user entered for field #1 times two and display the output.

The arithmetic tag only supports two operands.

The workaround if you need to add or multiply more than two things together is to use expressions and then add or multiply the expressions together:

<expression:1>[:arithmetic:{2}:+:{3}:]</expression>

<expression:2>[:arithmetic:{3}:*:{5}:]</expression>

[:arithmetic:{[:expression:1:]}:+:{[:expression:2:]}:]

This will show up in the Score Script output as

**20**. Note again that you can also use other Score Script tags as operands.

If the user puts in four numbers for fields 1 through 4 you could do something like the following to add them all together:

<expression:1>[:arithmetic:{[:info:1:user_response:]}:+:{[:info:2:user_response:]}:]</expression>

<expression:2>[:arithmetic:{[:info:3:user_response:]}:+:{[:info:4:user_response:]}:]</expression>

[:arithmetic:{[:expression:1:]}:+:{[:expression:2:]}:]

Usage example: **[:arithmetic:{[:info:5:user_response:]}:%:{2}:]** will be **0** if a number the website user entered for field #5 is even (evenly divisible by two), or **1** if a number the website user entered for field #5 is odd (not evenly divisible by two).

See the linked survey to see an example of this.