Sử dụng hàm viết 3 chương trình con tính tổng,hiệu,tích của 2 số nguyên m,n
2 câu trả lời
uses crt;
var m,n: integer;
{-------------------------------------}
Function Tong(a,b: integer): string;
begin
writeln(a+b);
end;
{-------------------------------------}
Function Hieu(a,b: integer): string;
begin
writeln(a-b);
end;
{-------------------------------------}
Function Tich(a,b: integer): string;
begin
writeln(a*b);
end;
{-------------------------------------}
BEGIN
clrscr;
write('Nhap m: '); readln(m);
write('Nhap n: '); readln(n);
writeln('m+n=',Tong(m,n));
writeln('m-n=',Hieu(m,n));
writeln('m*n=',Tich(m,n));
readln;
END.
uses crt;
var m,n: integer;
function Tong(a,b: integer): string;
begin write(a+b); end;
function Hieu(a,b: integer): string;
begin write(a-b); end;
function Tich(a,b: integer): string;
begin write(a*b); end;
begin
clrscr;
write('Nhap m: '); readln(m);
write('Nhap n: '); readln(n);
write('m+n=',Tong(m,n));
writeln;
write('m-n=',Hieu(m,n));
writeln;
write('m*n=',Tich(m,n));
writeln;
readln
end.