18.10.2014 Views

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SIMSCRIPT II.5 Programming Language

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

1. <strong>SIMSCRIPT</strong> <strong>II.5</strong> Basic Concepts<br />

1.1 Introduction<br />

A computer program is a list of instructions directing a computer to perform certain operations on<br />

data. A programming language is used by a programmer to describe the data and the actions to be<br />

performed. <strong>SIMSCRIPT</strong> <strong>II.5</strong> is one such programming language. Here is a simple example of a<br />

<strong>SIMSCRIPT</strong> <strong>II.5</strong> program:<br />

read X and Y<br />

add X to Y<br />

print 1 line with Y thus<br />

The Sum is: *****<br />

stop<br />

This program consists of four <strong>SIMSCRIPT</strong> <strong>II.5</strong> statements. The statements are instructions to:<br />

1. Read the values of two variables called X and Y from input data<br />

2. Add these variables together<br />

3. Print the sum of the variables along with the explanatory message, The Sum is:, and<br />

4. Stop.<br />

The example illustrates the basic computer operations of input (reading data), computation (in this<br />

case, addition), and output (printing results).<br />

In program examples throughout this book, <strong>SIMSCRIPT</strong> words and commands will be printed in<br />

lower case characters. Variable names, routine names, and other user-supplied terms will be printed<br />

in upper case characters. Thus, in the above example, read, and, add, to, print, line,<br />

with, thus, and stop are all <strong>SIMSCRIPT</strong> words. X, Y, and the phrase, The Sum is: are expressions<br />

provided by the programmer. <strong>SIMSCRIPT</strong> words which appear in the text (apart from<br />

those in program examples) will appear in bold characters. Again, variable names appear in upper<br />

case characters. Finally, small segments of code are presented in the ‘courier’ font as shown<br />

above.<br />

Although <strong>SIMSCRIPT</strong> does support string variables, the rest of this chapter focuses on integers and<br />

reals. See paragraph 2.19.<br />

1.2 Variables<br />

As shown in the above example, programs use identifying names to refer to values of program variables.<br />

A variable is a data item that may take on different values as it is acted upon by operations.<br />

A program statement such as:<br />

add X to Y<br />

1

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

Saved successfully!

Ooh no, something went wrong!