Sample Programs

 

            I.Description

            This program demonstrates the text output function of the SIMULA programming language by displaying the message "Hello world!".

                 Source Code

Begin
    while 1=1 do begin
          outtext("Hello World!);
          outimage;
    end;
End;
 

Sample Run

	Hello World!

                            Program Notes

                                        This program has not been tested.

 

II.Description

This program finds out the average value and the highest value from a list of whole numbers

Source Code

BEGIN INTEGER X, N, SUM, MAX;
 
IF LASTITEM THEN OUTTEXT ("NULL LIST") ELSE
BEGIN SUM:=MAX:=ININT;
N:=1;
 
WHILE  LASTITEM DC
BEGIN X:=ININT;
N:=N+1;
IF X > MAX THEN MAX:=X;
SUM:=SUM+X;
END;
OUTTEXT("LIST LENGTH = ");      OUTINT (N, 6);
OUTTEXT(",            HIGHEST = ");     OUTINT (MAX, 6);
OUTTEXT(",      AVERAGE = ");   OUTFIX (SUM/N, 2,, 8);
 
END;
OUTIMAGE;
END

Sample Run

**INPUT 1:
**OUTPUT 1:
NULL LIST
 
**INPUT 2:
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6
**OUTPUT 2:
LIST LENGTH=    21,     HIGHEST=        9,      AVERAGE=        4.90

Program Notes

This program has not been tested

<<prev                home                next>>