3

I have made a function with 2 parameters with the same data type and I have no problem with that.

But I'm having trouble with different data type

Here's my code :

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.

But It returned this error message:

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

1
  • A comma is used if you have more than one parameter tagged with the same type: a, b: string versus a: string; b: string or a: string: b: integer. Commented Oct 14, 2015 at 11:29

1 Answer 1

10

In Pascal you separate the arguments with a ;. So your definition has to look like this:

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

When you call the function then you still use a , to separate the parameters:

inputscore('David', 98);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.