## Algorithmic Syntax

A variable is a named object that can be modified during recalculation. Each variable has a unique name and a "scope" or context where it is identified. In the ExamView Test Generator, the scope of a variable is either limited to a single question, a narrative and all questions linked to it, or to a matching group and all questions within that matching group.

All variables are one of the following types:

int |
integer (positive and negative whole numbers and zero) |

double |
double-precision floating point (has fractional part) |

string |
characters or letters |

A variable name must begin with an alphabetic character, cannot be longer than 40 characters, and cannot contain characters other than alphabetic characters, numeric characters, and the underscore.

An expression is a mathematical, logical, or string phrase that contains constants, variables, operators, and keywords. An expression is used to define a variable.

**EXAMPLE**

y = x + 8

In this example, "y" is a variable being defined, "x" is a variable already defined, "+" is an arithmetic operator to do addition, and "8" is a numeric constant. You do not have to explicitly assign a type to any variable or constant. The program does that for you.

ExamView Test Generator uses the following arithmetic operators:

+ |
Addition (can also concatenate two string variables or constants) |

- |
Subtraction |

* |
Multiplication (use 3 * x instead of 3x) |

/ |
Division |

\ |
Integer division |

% |
Modulus |

^ |
Power (use x^2 to represent x to the 2nd power) |

! |
Factorial |

In addition to the arithmetic operators, ExamView Test Generator uses the following relational operators:

= |
Equals |

< |
Less than |

<= |
Less than or equal to |

> |
Greater than |

>= |
Greater than or equal to |

<> |
Not equal to |

& |
And (you can also use "and") |

| |
Or (you can also use "or") |

An expression that adds two strings together might look like this:

y = "Mrs. " + firstName + " " + lastName

In this case, "Mrs."; and the space between the first and last name are considered string constants. The variables firstName and lastName would have already been defined as string variables. When the expression has been evaluated, y will be a string variable.

ExamView Test Generator will not let you combine variables of different types when writing expressions, except where variables of a particular type are expected.

**EXAMPLE**

For example, you could not write an expression like:

y = "Mrs. " + 8 * x

The program would not know whether the string constant "Mrs."; should be treated as a numeric variable and added to the product of 8 times x, or whether the product of 8 * x should be treated as a string variable and concatenated to "Mrs."; to give the string result y.

The list of keywords shows what types of variables or constants can be used as arguments (input) to the various functions, as well as what type of variable gets created by the keyword or function (output).

ExamView Test Generator also lets you use parentheses to assign precedence to parts of your expressions when the program evaluates them. The following list will help you when determining the order in which an expression is evaluated:

( ) |
parentheses |

! + - |
factorial, positive, negative |

^ |
power |

* / \ % |
multiplication, division, integer division, modulus |

+ - |
addition, subtraction |

< <= > >= |
less than, less than or equals, greater than, greater than or equals |

= <> |
equals, not equals |

& |
and |

| |
or |