program Calculator4(input, output);
var x1, x2, apotelesma: real;
praxh: char;
function PROSTHESE (x, y : real ): real;
begin
PROSTHESE := x + y
end;
function AFAIRESE (x, y : real ): real;
begin
AFAIRESE := x – y
end;
function POLLAPLASIASE (x, y : real ): real;
begin
POLLAPLASIASE := x * y
end;
function DIAIRESE (x, y : real ): real;
begin
DIAIRESE := x / y
end;
begin
writeln(output, ‘EISAGETE: telesti x1 x2’);
readln(input, praxh, x1, x2);
case praxh of
‘+’ : apotelesma := PROSTHESE (x1, x2);
‘-‘ : apotelesma := AFAIRESE (x1, x2);
‘*’ : apotelesma := POLLAPLASIASE (x1, x2);
‘/’ : if x2 <> 0 then apotelesma := DIAIRESE (x1, x2)
else writeln(output, ‘ADYNATH DIAIRESH’);
else writeln(output, ‘LA8OS EISAGVGH DEDOMENVN’);
end {case};
writeln(output, x1, ‘ ‘, praxh, ‘ ‘, x2, ‘ = ‘, apotelesma);end. {Calculator4}
Κοµπιουτεράκι µε functions
Filed UnderΚαλωσήρθατε στην ιστοσελίδα μας