Program Statements and Constructs
A statement is the basic building block of a program and has to be constructed using the
strict syntax (guide lines and rules) of the programming language being used. Below is a
table of common programming statements and constructs:
Input
Syntax: READ <Variable> or INPUT <Variable>
Description: Accept input from users and store in the variable (eg. Memory)
Example: READ firstname or INPUT firstname
Results: allows the user to type in a name and stores this in memory with the variable name
firstname
Assignment (storage)
Syntax: LET <variable> = <expression>
Or <variable> = <expression>
Description: stores the results of the expression in the variable that is memory.
Example : LET firstname = ‘jackie’ or firstname = ‘jackie’
Result: stores the value Jackie in memory with the variable firstname.
Output
Syntax: PRINT <variable1>,<variable2>
OR
WRITE <variable1>,<variable2>
Description: Outputs contents of all the listed variables to the printer.
Example: PRINT firstname or WRITE firstname
Prints:Jackie
Control –Conditional
Syntax: IF <condition > THEN <statements>
ENDIF
Description: Executes the statements only if the condition is true
Example: IF age>17 THEN
PRINT ‘Adult’
ENDIF
Results: Prints the word Adult only if the value stored in the variable age is greater than 17

Program statements and constructs

  • 1.
    Program Statements andConstructs A statement is the basic building block of a program and has to be constructed using the strict syntax (guide lines and rules) of the programming language being used. Below is a table of common programming statements and constructs: Input Syntax: READ <Variable> or INPUT <Variable> Description: Accept input from users and store in the variable (eg. Memory) Example: READ firstname or INPUT firstname Results: allows the user to type in a name and stores this in memory with the variable name firstname Assignment (storage) Syntax: LET <variable> = <expression> Or <variable> = <expression> Description: stores the results of the expression in the variable that is memory. Example : LET firstname = ‘jackie’ or firstname = ‘jackie’ Result: stores the value Jackie in memory with the variable firstname. Output Syntax: PRINT <variable1>,<variable2> OR WRITE <variable1>,<variable2> Description: Outputs contents of all the listed variables to the printer. Example: PRINT firstname or WRITE firstname Prints:Jackie Control –Conditional Syntax: IF <condition > THEN <statements>
  • 2.
    ENDIF Description: Executes thestatements only if the condition is true Example: IF age>17 THEN PRINT ‘Adult’ ENDIF Results: Prints the word Adult only if the value stored in the variable age is greater than 17