I keep getting this can you guys look at my code and see whats up

PROGRAM LargeandSmall;
USES Wincrt;
{*----------------------------------------------------------------------*/
var
        Nums:Array[1..10] of INTEGER;
        Largest:INTEGER;
        Smallest:INTEGER;
        menuchoice:INTEGER;
        i:INTEGER;
        anykey:CHAR;
{*-----------------------------------------------------------------------*/
PROCEDURE initialise;
VAR
        i:INTEGER;
BEGIN
        FOR i:=1 to 10 DO
                num[i]:=0
        Largest:=0;
        Smallest:=32767;
End;
{*-----------------------------------------------------------------------*/
FUNCTION get_menu_choice;
VAR
        i:INTEGER;
        choice:integer;
Begin
        FOR i:=1 to 10 DO
                Writeln;
        Writeln('              LARGE & SMALL MENU');Writeln;Writeln;
        Writeln('              1.  Ten numbers')Writeln;
        Writeln('              2.  Any numbers, terminate with 999');Writeln;
        Writeln('              3.  Exit');Writeln;Writeln,Writeln;
        Writeln;Writeln;Writeln;Writeln;
        Write('Please enter your choice:');
        Readln(choice)
        get_menu_choice:=choice;
End
{*------------------------------------------------------------------------*/
Function getnum;
VAR

        num : INTEGER;
        i : INTEGER;
BEGIN
        Repeat
                FOR I:=1 to 10 DO
                        Writeln;
                Write('Enter a number: ');
                Readln (num);
                If num <=0 THEN
                BEGIN
                        Writeln('Invalid number, try again');Writeln;
                        Writeln;Writeln;Writeln;
                End;
        UNTIL num>0
        getnum:=num;
END
{*-------------------------------------------------------------------------*/
BEGIN
        REPEAT
                initialise
                menuchoice:=get_menu_choice;
                CASE menuchoice OF
                1:      BEGIN
                        FOR I:=1 to 10 DO
                                BEGIN
                                num[i]:=getnum
                                IF nums[i]>Largest THEN
                                        Largest:=num[i];
                                IF nums[i]<Smallest THEN
                                        Smallest:=nums[i];
                                END;
            End;
                2:       BEGIN
                         i:=0;
                         nums[i]:=getnum
                         While nums[i]<>999 DO
                                BEGIN
                                IF nums[i]>Largest TEN
                                        Largest:=nums[i];
                                IF nums[i]<Smallest THEN
                                        Smallest:=nums[i];
                                i:=i+1;
                                nums[i]:=getnum;
                                END
                         Writeln;Writeln;Writeln;
                         Writeln('          The largest numbers is: ',Largest);
                         Writeln;Writeln;Writeln;
                         Writeln('          The smallest numbers is: ',Smallest;
                         Writeln('Press any key to return to menu');
                         anykey:=readkey;
                         END;
                3:       Writeln('Exit chosen.....');
                OTHERWISE:
                        Writeln('Incorrect selection, try again');Writeln;
        UNTIL menuchoice=3;
END.

Dani AI

Generated

The compiler message "Fatal: Unexpected end of file" means the parser hit the end of the source while still expecting tokens (an END, a ), a ;, etc.). In the code posted by the root causes are syntax and token errors rather than a single logic bug: missing semicolons after statements and procedure calls, a misspelled keyword (TEN for THEN), an unterminated Writeln( call, function headers with no return type, inconsistent names (Nums vs num), and an array-index start of 0 for an Array[1..10]. Any one of those can confuse the parser enough to reach EOF unexpectedly.

Concrete fixes to apply (compile after each change):

  • Give functions explicit result types: use function get_menu_choice: Integer; and function getnum: Integer;.
  • Always terminate statements and calls with ; (including procedure calls like initialise;).
  • Fix the typo TEN -> THEN and close any unmatched parentheses in Writeln calls.
  • Use the declared array name consistently (Nums[...]) and start indexing at 1 for Array[1..10] (or change the array bounds).
  • Initialize Largest/Smallest safely (or set them from the first valid input instead of magic constants).

Example of minimal corrected declarations and a few safe lines:

function get_menu_choice: Integer;
function getnum: Integer;
procedure initialise;
initialise;
menuchoice := get_menu_choice;
i := 1;   { start index inside declared array bounds }
Writeln('The smallest number is: ', Smallest);

Practical tips: fix the first compiler error and recompile — later errors often cascade from the first. Prefer initializing Largest/Smallest from the first read value rather than hard-coded extremes. If ReadKey is used and the compiler complains, add the unit that provides it (for many Pascal compilers that is Crt). The brief reply from to "debug" is correct in spirit; follow a stepwise edit/compile cycle and the unexpected-EOF will disappear once the syntax mismatches are fixed.

How about you to try to debug your code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.