如何在 Pascal 中使用具有不同数据类型的多个参数制作函数?

How to make function with multiple parameters with different data type in pascal?

我创建了一个函数,其中包含 2 个具有相同数据类型的参数,我没有遇到任何问题。

但是我在处理不同的数据类型时遇到了问题

这是我的代码:

uses crt;
function inputscore(name : string, score:integer) : integer;

begin
     writeln('My name is ',name,' and my score is ',score);
     inputscore:=0;
end;

begin
    clrscr;

    inputscore('David',98);
    readkey;
end.

但是它返回了这个错误信息:

multipleparameterfunc.pas(2,34)Fatal syntax error, ")" expected but "," found

在 Pascal 中,您使用 ; 分隔参数。 所以你的定义必须是这样的:

function inputscore(name: string; score: integer) : integer;

当你调用函数时,你仍然使用一个,来分隔参数:

inputscore('David', 98);