REAL Z INTEGER ISUMThe user need not declare which are integers and which are reals if he or she stays with the implicit rule that all variables starting I,J,K,L,M or N are integers and the rest are reals. For compatibility all users are VERY STRONGLY URGED to obey this rule! EXPRESSIONS are made by combining constants and variables using:-
+- addition, subtraction */ multiplication, division ** exponentiation () brackets
The above list is shown in ascending priority so that expressions follow normal algebriac rules. Within any one priority the expression is evaluated left to right. So
3+2*4 is 11 (not 20) 8/2*2 is 8 (not 2) 3**2*4 is 36 (not 6561)When dividing integers the result is always rounded towards 0 so 3/2=1 and -3/2=-1. Expression may mix integers and reals in which case the integer number is always first converted to a real before being used. So if I contains the integer 3 and A the real 2.0 then I/A would produce the real 2.5. (Note the value in I is not changed). ASSIGNMENTS give new values to variables. They have the general form
variable=expressionFor example
N=1 A=-27.5 X=Y+Z/A J=J+1 L=Z+I
Note that the expression can involve the variable whose value is being changed. So if J has the value 2 then after J=J+1 it will have the value 3. If a real expression is assigned to an integer then it is rounded towards zero and if an integer expression is assigned to a real then it is converted by adding a zero fractional part.
A=2.5 B=5 C=B/A PRINT *,C STOP END
If you have typed it in properly the answer should be 2.0. Now change the variable A to IA and rerun the program. The first line has a real expression assigned to an integer, so it will be rounded towards zero and IA will contain 2. On the third line B/IA is a mixed expression so the value in IA will be converted to 2.0 before use and the result should be 2.5. Finally change B to IB and change the second line to IB=-5. Run the program again. This time IB/IA is an integer expression which produces an integer result, again rounded towards zero. It is then stored in C as -2.0