Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What does this error mean?

+1 vote
asked Feb 22, 2023 by Unai Sevilla (130 points)

I am programming in Pascal but I do not know where is the error. This is the program:

VAR
    iNum1, iNum2, iNum3 : Integer;
    
BEGIN
    Write('Introduce un numero entero: ');
    ReadLn(iNum1);
    Write('Introduce otro entero: ');
    ReadLn(iNum2);
    Write('Introduce otro entero: ');
    ReadLn(iNum3);
    
    IF (iNum1 > iNum2) AND (iNum1 > iNum3) THEN
        BEGIN
        Write('El valor mayor es: ', iNum1);
        ReadLn;
        END
    
    ELSE IF (iNum1 < iNum2) AND (iNum2 > iNum3) THEN
        BEGIN
        Write('El valor mayor es: ', iNum2);
        ReadLn;
        END
    
    ELSE IF (iNum1 > iNum2) AND (iNum2 < iNum3) THEN
        BEGIN
        Write('El valor mayor es: ', iNum3);
        ReadLn;
        END;
END.

And the error says:

main.pas(1,9) Fatal: Syntax error, "identifier" expected but "ordinal const" found
Can someone help me please?

1 Answer

0 votes
answered Feb 23, 2023 by Peter Minarik (86,680 points)

The error means that the compiler was looking for a name (and identifier), but instead, it found a number (ordinal const).

As for your code, if I copy the code you provided, it compiles and runs.

Your logic, however, does not work correctly for all scenarios.

For instance, for the input [1, 2, 3] your program does not find the largest number (3).

Review the last if statement to fix the problem.

Good luck!

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...