A SIMPLE Pascal Program

A SIMPLE Pascal Program
Write a program to print the words 'Hello. How are you?' on the console screen.


program MYFIRST (output);
begin
writeln('Hello. How are you?')
end.


The keyword writeln writes text to the console screen. The text to be displayed is written inside single quotes. After printing the text inside the single quotes, the cursor is positioned to the beginning of the next line.

To print a single quote as part of the text, then use two quotes, eg,


program TWOQUOTES (output);
begin
writeln('Hello there. I''m fine.')
end.


program output is;
Hello there. I'm fine.
_

Note the underscore character represents the position of the cursor

write versus writeln
The write statement leaves the cursor at the end of the current ouput, rather than going to a new line. By replacing the above program with a write statement, the result is,


program TWOQUOTES (output);
begin
write('Hello there. I''m fine.')
end.


program output is;
Hello there. I'm fine._

Note the underscore character represents the position of the cursor
0 Komentar untuk "A SIMPLE Pascal Program"

Back To Top