Home computickets How to deal with the error “A procedure or function name was...

# How to deal with the error “A procedure or function name was expected”?

Author

Date

Category

I can’t deduce the function in any way, something is wrong all the time.

Here is my code, marked the line with the error text:

``````var
x, y: real;
n: byte;
begin
writeln ('enter x');
if x & lt; = - 05 then
begin
y: = cos (sqrt (exp (yln (1/5) (abs (x + ln (abs (x))))))); // & lt; & lt; & lt; --- Expected procedure or function name
n: = 1
end
else if (x & gt; -0.5) and (x & lt; = 0.5) then
begin
y: = cos (exp (abs (x + ln (abs (x)))));
n: = 2
end
else
begin
y: = exp ((yln (1/3))) (exp (x)) (sqrt (x + 1)) - pi;
n: = 3
end;
writeln ('x =', x: 6: 2, 'y =', y: 6: 2, 'n =', n: 3);
end.
``````

In almost all programming languages, you cannot omit the multiplication sign. And in the above code, there are not even spaces in its place.

In all places where multiplication is implied, there must be a `* `symbol.

The second error is that a comma is used as a decimal separator in numbers: `0.5 `, and there must be a period: `0.5 `.

Let’s start describing the first formula:

1-1) & nbsp; & nbsp; `y: = x * x `is x²

1-2) & nbsp; & nbsp; `y: = x * x + sqr () `is the square for the tangent

1-3) & nbsp; & nbsp; `y: = x * x + sqr (sin () / cos ()) `is the tangent itself, which is not in pascal

1-4) & nbsp; & nbsp; in brackets sin and cos you need to add `(x + pi) / 2 `

As a result, the first formula turned out like this:

`y: = x * x + sqr (sin ((x + pi) / 2) / cos ((x + pi) / 2)) `

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~

Second:

2-1) & nbsp; & nbsp; `y: = cos () `– this is clear so

2-2) & nbsp; & nbsp; `y: = cos (exp (ln () / 5)) `– fifth root

2-2) & nbsp; & nbsp; `y: = cos (exp (ln (abs (x + ln (abs (x)))) / 5)) `– it’s just

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~

Third:

3-1) & nbsp; & nbsp; `y: = exp (ln () / 3) `– root of the third degree

3-2) & nbsp; & nbsp; `y: = exp (ln (x + exp (x) * sqrt (x + 1) - pi) / 3) `– add only what under the root

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~

This is the whole program:

``````var
x, y: real;
begin
writeln ('enter x');
if x & lt; = -0.5 then
y: = x * x + sqr (sin ((x + pi) / 2) / cos ((x + pi) / 2))
else if x & gt; +0.5 then
y: = exp (ln (x + exp (x) * sqrt (x + 1) - pi) / 3)
else {-0.5 & lt; x & lt; = +0.5}
y: = cos (exp (ln (abs (x + ln (abs (x)))) / 5));
writeln ('y (', x: 6: 2, ') =', y: 6: 2);
end.
``````

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.