Is the example program correct?
No—the brackets are not balanced.
DO
must match LOOP
:
PRINT "Enter the number of repeats" INPUT LIMIT LET COUNT=1 DO WHILE COUNT <= LIMIT IF COUNT < LIMIT / 2 THEN PRINT "Hello" ELSE PRINT "Mars" LOOP PRINT "Done" END IF END
But now the "inside bracket" IF
does not have an "inside bracket" End IF
to
match.
The program is NOT correct.
Here is a corrected version:
PRINT "Enter the number of repeats" INPUT LIMIT LET COUNT=1 DO WHILE COUNT <= LIMIT IF COUNT < LIMIT / 2 THEN PRINT "Hello" ELSE PRINT "Mars" END IF LOOP PRINT "Done" END
The inside bracket IF now has another inside bracket END IF which it can match. Another way to think about this is that the loop body should be a complete self-contained little task, with all its control structures complete. So any brackets for those control structures must be matched inside the loop body.
Is the following ALGEBRA correct?
X = [ ( 2Y + 3)( Z - 2) ] / ( B + A )(Don't figure out what it means (if anything), just decide if it looks OK.)