| | |
Fatal: Unexpected end of file
![]() |
•
•
Join Date: Apr 2006
Posts: 1
Reputation:
Solved Threads: 0
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.
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.
![]() |
Similar Threads
- Pascal Help (Pascal and Delphi)
- ERROR--Unexpected end to file (C++)
- Compression/Decompression Wave File to MP3 and Vice Versa (C++)
- C++ complete binary tree using an array. Unexpected end file (C++)
- Fatal Error C010? (C)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: What is the Easiest way to convert TP to VB
- Next Thread: Convert binary into text/text into binary
| Thread Tools | Search this Thread |





