By Niklaus Wirth
This article is an creation to programming mostly, and a guide for programming with
the language Modula-2 specifically. it truly is orientated essentially in the direction of those who have
already obtained a few uncomplicated wisdom of programming and want to deepen their
understanding in a extra based approach. however, an introductory bankruptcy is included
for the advantage of the newbie, exhibiting in a concise shape a number of the fundamental
concepts of desktops and their programming. The textual content is as a result additionally compatible as a
self-contained educational. The notation used is Modula-2, which lends itself good for a
structured strategy and leads the coed to a operating type that has as a rule become
known below the name of based programming.
Read Online or Download Programming in Modula-2 PDF
Best programming: programming languages books
Réaliser des websites dynamiques en Flash avec ActionScript, MySQL et Hypertext Preprocessor (versions five ou 4). remark afficher sur web des données en temps réel, tels les résultats d'une élection ou le rating d'un fit de tennis ? Grâce à Flash eight, personal home page et MySQL, qui permettent de concevoir des interfaces internet graphiques et conviviales, couplées à des bases de données.
- NetBeans 6. Rich-Client-Entwicklung mit Java
- VBA mit Excel 2000
- Big Java. Compatible with Java 5, 6 and 7, 4th Edition
- Die C++-Standardbibliothek: Einführung und Nachschlagewerk, 4. Auflage
- The Definitive Guide to Java Swing, 3rd Edition
Extra info for Programming in Modula-2
A function procedure specifies a result which is used at its place of call as an argument of an expression. 2. The result of a function procedure cannot be structured. 3. If a function procedure generates secondary results, it is said to have side-effects. These must be used with care. It is advisable to use a regular procedure instead, which passes its results via VAR parameters. 4. We recommend to choose function identifiers which are nouns. The noun then denotes S3 the function's result. Boolean functions are appropriately labelled by an adjective.
Which are obtained by storing previously computed results. M ... no. ) VAR i,k,x: CARDINAL; inc, lim, square, L: CARDINAL; prime: BOOLEAN; P,V: ARRAY [O.. M] OF CARDINAL; BEGINL:= 0; x : = 1; inc: = 4; lim : = 1; square: 9; FORi:= 3TONDO (. ) REPEAT x : = x + inc; inc: = 6· inc; IF square < = x THEN lim:= lim + 1; V[lim]:= square; square: = P[lIm + 1]. P[k] END; prime: = x # V[k] END UNTIL prime; . IF i<= MTHEN P[i]:= x END; WriteCard(x,6); L : = L + 1; IFL = LL THEN WriteLn; L : = 0 END = 42 END END Primes.
PROCEDURE np(n: CARDINAL): CARDINAL; BEGIN IF n <.. 1 THEN RETURN 1 ELSE RETURN n - np(n·1) END ENDnp We recognize np as the factorial function, which can also be expressed as np(n) = 1-2-3- ... -n This formula suggests to program the algorithm using repetition instead of recursion PROCEDURE np(n: CARDINAL): CARDINAL; VAR p: CARDINAL; BEGINp:= 1; WHILEn>1 DO p:= n-p;n:= n·1 END; RETURNp ENDnp This formulation will compute the result more efficiently than the recursive version. The reason is that every call requires some "administrative" instructions whose execution costs time.