- Code: Select all
program Untitled;
var op:integer;
var n:integer;
var n2:integer;
var ris:integer;
function add:integer;
begin
add:= n+n2;
end.
function sott:integer;
begin
sott:= n-n2;
end.
function molt:integer;
begin
molt:= n*n2;
end.
function divi:integer;
begin
divi:= n/n2;
end.
begin
writeln ('Calcolatrice, esegue le operazioni di base');
writeln;
writeln ('Inserisci il primo numero');
writeln;
readln (n);
writeln ('Inserisci l''operatore da usare (+, -, *, /)');
writeln;
readln (op);
writeln ('Inserisci il secondo numero');
writeln;
readln (n2);
if op = + then ris:= add;
if op = - then ris:= sott;
if op = * then ris:= molt;
if op = / then ris:= divi;
writeln ('Il risultato è: ',ris);
writeln;
end.
premetto che nn sono molto sicuro che quelo che ho fatto sia giusto...+ che altro sono andato per logica...


