|
|
-The language is case sensitive. -It has two kinds of statements: an assignment statement and a print statement. -A statement is terminated by a semicolon. -There is one reserved word “print”. -You can define variables, reserved words can not be used as variable names, otherwise, the variable name is a combination of letters(a ..z, A.. Z). For example, x, aBc, Klasses are valid, but A1, print are not. -The assignment statement takes the form “variable = expression”, it assigns the result of the expression to the variable. -The expression contains integer numbers, variables and binary operators +(add), –(subtract), *(multiply), and /(quotient). For example, 10+3/59, 2*a/pbs + 10 -30 are valid expressions, 10 + + b – c is not. -The standard rules on operator precedence apply. -Blanks can appear anywhere just like the way in C++. -An assignment statement such as xy=abc+3/50 is valid, so is xy = abc + 3 / 50. -A print statement takes the form “print variable(s)”, it displays the value(s) of the variables on the screen. -The variable(s) can be one variable, or more than one variable separated by blanks. For example, print a; print a b cbs; are valid print statements. -For assignment statement, the expression to the right of the equal sign is evaluated and the result is assigned to the variable to the left of the equal sign; for print statement, the name of the variable and the value of it with a equal sign in between will be displayed, one pair per line. -Your program will assign the value 2 to variable A, assign the value 0(A – 2) to variable c, and stops while trying to evaluate A/c (2/0). An output like “RUN TIME ERROR: divide by 0” should appear on the screen and your program will stop and the rest of the user program is ignored. If you want to be more user friendly, you can indicate where but that is not mandatory. The use program died because it tries to divide by zero. If a variable is referenced without having previously assigned a value, a default value of zero shall be used. |
|
|