Inside the loop values of n are read and added to sum

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: rted only static data. 3. Use of pointer variables that facilitate two distinct kinds of uses - (a) they allow indirect addressing (can be used to point to other data items), which is heavily used in assembly language programming, and (b) they provide a method of dynamic storage management (programmers can allocate a piece of dynamic storage and set a pointer to its address). 4. Addition of new control statements to facilitate easier programming. These include CASE statement for multiple options selection, EXIT statement for prematurely departing from a loop, and CYCLE statement for transferring control to the bottom of a loop but not out. As FORTRAN language is oriented towards solving problems of a mathematical nature, it has been designed as an algebra-based programming language. Any formula or mathematical relationships that can be expressed algebraically can easily be expressed as a FORTRAN instruction, for example, A = B + C - D. To illustrate the nature of FORTRAN programs, a simple FORTRAN program to compute and print the sum of 10 numbers is given in Figure 12.16. C FORTRAN PROGRAM TO COMPUTE C THE SUM OF 10 NUMBERS SUM = 0 DO 50 I =1,10 READ (5, 10) N SUM = SUM + N 50 CONTINUE WRITE (6, 20) SUM 10 FORMAT (F6.2) 20 FORMAT (IX, 'THE SUM OF GIVEN NUMBERS = ', F10.2) STOP END It can be seen from the example of Figure 12.16 that a FORTRAN program consists of a series of statements for input/output, calculation, logic/comparison, etc. The words READ, WRITE, DO, CONTINUE, STOP, END, etc. in the statements mean exactly what one would expect. In the given example, the first two lines that begin with the character C are comment statements. Comment statements are used in programs for the purpose of documentation or explanation designed to assist anyone reading the source program listings. Comments do not form a part of the program logic and are ignored by the computer. In the third statement of the program, the value of SUM is initialized to zero. The next statement starts a DO loop. This loop ends in the line having label 50, wh...
View Full Document

This document was uploaded on 04/07/2014.

Ask a homework question - tutors are online