If using one variable in pseudocode is good, then using multiple variables is (probably better).
Don’t add variables you don’t need. As it will make it more complex than necessary. Always ask yourself, what is this variable here for.
Everything should be as simple as it can be, but not simpler.
Albert Einstein
To add additional variables, you can define them on a separate line, or on the same line – separated by commas.
If variables are of the same type, and used together, like to put them on the same line. Where, if they are of different types, or won’t be used together, I will put them on separate lines. This way we can group and organize information better.
define num1, num2
define name
define streetAddress, city, state, postalCode
Notice that I used camel case, or a form of naming that the first letter of each subsequent word is capitalized. This is common in C/C++, Java, and C#, among other languages. There is also snake case, where everything is lower case, with an underscore showing the joining of words. The Python programming language uses this most commonly, but other languages do as well. There are other naming conventions as well, such as Pascal Case, which isn’t as popular, and more.
Math with Multiple Variables
Math in Pseudocode is fairly simple. Addition, subtraction, etc all work as normal. Division is typically a forward slash /
and the modulus operator, is a percent sign (%
). We will follow your standard order of operations – PEMDAS as defined in the US. Some other countries will use other names, but algebra is algebra and all the operators will behave the same. If there are two operations that are the same – then we read left to right.
The answer always is assigned to the left side of the equation as you can see below.
x = 8 - num1
Multiple Variables in Pseudocode was originally found on Access 2 Learn