13.07.2015 Views

A practical introduction to Pascal programming language - GIARA

A practical introduction to Pascal programming language - GIARA

A practical introduction to Pascal programming language - GIARA

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1Basic read/write operations1.1 Contents of this chapterThis chapter covers the instructions used <strong>to</strong> gather data from the user, as well as displayinon-screen the information generated by a program. Its contents are:1.a Writing in the command line.1.b Reading from the keyboard.1.c Basic assignment operations.1.d Usage of simple functions provided by the <strong>programming</strong> framework.1.2 Brief reviewThis section cover the most basic read/write operations. There are two operations we can use <strong>to</strong>write text in the command line: write(t) - Writes the text t in the command line (more on the composition of t later). writeln(t) - Does the same as write(t), but jumps the line right after writing the text.That is, places the prompt at the beginning of the line following.The composition of the text <strong>to</strong> be displayed by write/writeln can be performed in differentways. These are the options:• Simple static text between simple quotations.writeln(’computer’).Some examples are write(’hello’) or• Concatenation of static texts. To do so, we only have <strong>to</strong> include as many pieces oftext as necessary, all of them separated by the comma symbol. Some examples arewrite(’hel’,’lo’) or writeln(’this ’,’is ’,’my computer’). Note that, for example,write(’hel’,’lo’) produces the same message on-screen than write(’hello’).• Concatenation of static text and non-static values. In this case we can combine the fixedtext with contents derived from the contents of the variables. To concatenate fixed textwith non-fixed content, we also use the comma symbol. Some examples are write(’211

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!