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.
	Sample Program Output
	Hello. How are you?
	_

 

The above shows both the program, and its sample output which is printed as a result of running the program.

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.


	Sample 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 output, 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.
	
	
	Sample program output is;
	Hello there. I'm fine._
	
	Note the underscore character represents the position of the cursor

Exercise 1: Write a program to print the following words on the console screen.

	Hello. How are you?
	I'm just fine.
	
	Click here for answer

© Copyright B Brown/P Henry, 1988-1999. All rights reserved.