sintassi con turbo pascal 1.1 su mac
program bas4; { uso di IF...THEN..ELSE }
var a:integer;
procedure fine; begin writeln('premi return per finire'); readln; end;
begin CLEARSCREEN; writeln('scrivi un numero:1,2,3 '); readln(a); CLEARSCREEN; if a=1 then writeln(a) else if a=2 then begin writeln(a*10); writeln(a); end else if a=3 then begin writeln(a); writeln(a*10); writeln(a*100); end; fine; end.
program base4; { uso di FOR....DO }
var a,b,c,d:integer;
procedure fine; begin writeln('premi return per finire'); readln; end;
begin CLEARSCREEN; b:=0; writeln('quanti numeri devi inserire? '); readln(d); clearscreen; for a:=1 to d do begin writeln('scrivi un numero intero '); readln(c); b:=b+c; writeln(b) end; fine; end.
program base4A; { uso di WHILE.DO }
var b,c,d,x:integer;
procedure fine; begin writeln('premi return per finire'); readln; end;
begin CLEARSCREEN; b:=0; x:=1; writeln('quanti numeri devi inserire? '); readln(d); D:=D+1; clearscreen; WHILE x < d do begin writeln('scrivi un numero intero '); readln(c); b:=b+c; writeln(b); x:=x+1; end; fine; end.
PROGRAM BASE8;
LABEL 100,200,300,400; VAR A:INTEGER; BEGIN WRITELN('scrivi un numero come 1,2,3'); readln(a); clearscreen; if a=1 then goto 100; if a=2 then goto 200; if a=3 then goto 300;
100:writeln('chiamata label 100');goto 400; 200:writeln('chiamata label 200');goto 400; 300:writeln('chiamata label 300');goto 400; 400:writeln('premi return per finire'); readln; end.
PROGRAM BASE9;
LABEL 100,200,300,400; VAR A:INTEGER; BEGIN WRITELN('scrivi un numero come 1,2,3'); readln(a); clearscreen;
CASE A OF 1 : goto 100; 2: goto 200; 3: goto 300; END;
100:writeln('chiamata label 100');GOTO 400; 200:writeln('chiamata label 200');goto 400; 300:writeln('chiamata label 300');goto 400; 400:writeln('premi return per finire'); readln; end.
PROGRAM BASE9A;
LABEL 100,200,300,400; VAR A:INTEGER; BEGIN WRITELN('scrivi un numero come 1,2,3'); readln(a); clearscreen;
CASE A OF 1 : goto 100; 2: goto 200; 3: goto 300; OTHERWISE GOTO 400; END;
100:writeln('chiamata label 100');GOTO 400; 200:writeln('chiamata label 200');goto 400; 300:writeln('chiamata label 300');goto 400; 400:writeln('premi return per finire'); readln; end.