CSM 157 PROGRAMMING-Week3
CSM 157 PROGRAMMING-Week3
• Input statements allow data to be entered into a variable during program execution.
• Note that an input data can be read from a file. For now, input will be entered via the
keyboard.
• When we want to ask a user to enter data during program execution, we will make use
of any of the following verbs and the format:
- INPUT
∞
- READ variable , 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒
0
- ACCEPT
- GET
Eg. To receive 10, 5 and 30 into the variables A, B and C, we will write
INPUT A
INPUT B
INPUT C
Input Statements
• One input statement can be used to receive one or more data. The
names of the variables should be separated by commas. The input
statements
INPUT A
INPUT B
INPUT C
Can be written as
INPUT A, B, C
Output Statements
• Output statements allow information to be displayed on the screen
• Outputs statements also allow information to be written to a file. For
now, we want our outputs to be displayed on the screen
• When we want information to be displayed on the screen during
program execution, we will make use of any of the following verbs
with the format:
- WRITE
∞
- PRINT item , 𝑖𝑡𝑒𝑚 0
- OOUPUT
- DISPLAY
• One output statement can be used for one, two or more items
separated by commas
Output Statements
• The output statements can be used to display different kinds of item.
The following are typical examples of the item
• WRITE “What is your name?” will display the string What is your name?
• WRITE A, B will display the values in the variables A and B
• Operators are usually found between two operands except when they
are Unary . An operand is any object such as constant, variable, string
and function
Mathematical or Arithmetic Operators
• Generally, the following are the arithmetic operators:
• + for addition,
• - for subtraction,
• * for multiplication,
• = lowest precedence
• Arithmetic operators of the same order are evaluated from left to right in
any given expression
Relational (comparison) Operators
• Generally, the following are the operators used in comparing two items
= equal to
!= or <> Not equal to
< less than
<= less than or equal to
> Greater than
>= Greater than or equal to
(Note how the less than or equal to, and greater than or equal to are written,
the symbols cannot be interchanged)
Logical Operators
• These are used when relational tests are to be combined.
• Generally, the logical operators are:
& and
ǀ or
^ exclusive or
! Not