Controlling Computers with Programs When you create a computer program you are creating a set of instructions that tell the computer exactly and completely what to do. Computers operate using a language that is usually unique to each brand and model, called machine code.
Machine Coding The Binary System – All 0s and 1s Hexadecimal - A Base16 number system Assembly Language – A human–readable form of machine code for every microprocessor. Assemblers – convert the assembly language programs into machine code.
Object-oriented Programming C and C++ are procedural languages. They are designed to allow programmers to solve problems by defining the procedures to use. With OOPS, programmers have a means to describe the relationships between collections of code and variables known as objects.
Torque Script Torque Script is typeless and does not require forward declarations of variables. Also Torque Script requires scope prefixes (like % signs for local and $ for global variables. Variables typically require a “type” to specify how much memory will be used. Torque script does not require this.
Some Definitions Expressions – Statements that can be evaluated Variables – chunks of memory where values are stored. Arrays – A data structure that allows a collective name to be given to a group of elements of the same type. Strings – like an array of single characters
Loops Loops are used for repetitive tasks With While loops the condition is evaluated before the loop body statements are executed. For Loops While Loops
Functions Functions save work. Once you’ve written code to solve a problem, you can roll the code into a function and reuse it whenever you encounter that problem again. You can also use the code with different starting parameters.
Conditional Expressions A conditional or logical expression is an expression that can only evaluate to one of two values: true or false. There are also explicit logical operators for combining the logical values of true and false.
Branching The term branching refers to the idea that code can follow different execution paths. The simplest way to select the next thing to do in a program based on conditions is to use the if statement. The if-else statement can be used for multiple branches. These statements can also be nested one inside the other.
Debugging and Problem Solving Missing Semicolon at the end of a statement Missing slash in a double-slash operator Missing % or $ (scope prefix) from variable names Using uninitalized variables Mixing global and local scope prefixes Unbalanced parentheses or braces