sintassi con turbo pascal 1.1 su mac
program aree;
type poligoni=(triangolo,quadrato,pentagono,esagono); var poligono:poligoni; nome:string; numero:integer;
function area(numero:integer):real; begin area:=numero/2*sin(2*PI/numero); end;
begin writeln('indica poligono desiderato'); writeln('triangolo,quadrato,pentagono,esagono'); readln(nome); if nome='triangolo' then numero:=ord(triangolo)+3; if nome='quadrato' then numero:=ord(quadrato)+3; if nome='pentagono' then numero:=ord(pentagono)+3; if nome='esagono' then numero:=ord(esagono)+3; writeln(numero,' lati....area=',area(numero):12:10); writeln('premi return'); readln; end.
program funzio1;
var a,b:integer; c,d:real;
function fun1(x,y:integer):integer; begin fun1:=x*Y; end;
function fun2(x,y:real):real; begin fun2:=x/Y; end;
begin a:=10; b:=20; c:=125.50; d:=10.5; writeln(fun1(a,b)); writeln(fun2(c,d):5:2); writeln; writeln(fun1(6,6)); writeln(fun2(120,11):5:3); writeln; writeln('premi return'); readln; end.
program funzio2;
var a,b:integer; c,d:real;
function fun1(x,y:integer):integer; begin fun1:=x*Y; end;
function fun2(x,y:real):real; begin fun2:=x/Y; end;
procedure area1(x,y:integer); var area:real; begin area:=(X*Y)/2; writeln('area=',area); end;
procedure area2(x,y:integer); var area:integer; begin area:=(X*Y); writeln('area=',area); end;
begin a:=10; b:=20; c:=125.50; d:=10.5; writeln(fun1(a,b)); writeln(fun2(c,d):5:2); writeln; writeln(fun1(6,6)); writeln(fun2(120,11):5:3); writeln; area1(10,20); area1(30,30); area2(fun1(a,b),fun1(5,6)); writeln('premi return'); readln; end.