High-level Programming Language (Pascal)
Program Input and Output
To be useful, a program needs some means to communicate with the user. They are input statements and output statements.
read (<input list>)
readln (<input list>)
readln
|
Type
of Argument
|
Action
of read on the argument
|
|
char
|
Assign the next input character to its argument |
|
integer
|
Skip any blank, tab or carriage return, then read an integer that must end with a blank, tab or carriage return. The ending character is not read. |
|
real
|
Same as integer but a real number is read. |
|
string
|
Read all characters up to, but not including the carriage return. |
write (<output list>)
writeln (<output list>)
writeln
|
Action
|
Statement
|
Output
|
| 12345678901234567 | ||
| Printing
a number ¡@Positive integer ¡@Negative integer ¡@Real number |
writeln (123); writeln (-123); writeln (123.0); |
123 -123 1.230000000E+02 |
| Printing a character | writeln ('A'); | A |
| Printing a string | writeln ('Hello'); | Hello |
| Printing a list of data items | writeln
('A', 'B', 'C'); writeln ('Hello', 'John'); writeln (1, '+', 2, 'is ', 3); |
ABC HelloJohn 1+2 is 3 |
| Printing an expression | writeln ('Sum = ', 2 + 6); | Sum = 8 |
| Printing Boolean | writeln ('3>2 is ', 3>2); | 3>2 is TRUE |
|
Statements
|
Output
|
| 123456789012345678901234567 | |
| writeln
('Hello'); writeln ('Welcome to Pascal Programming'); |
Hello Welcome to Pascal Programming |
| write
('Hello'); write ('Welcome to Pascal Programming'); |
HelloWelcome to Pascal Programming |