Write a program that prints itself.
Here is SELFPRT.BAS, a QBasic program:
LET NUMLINES%=10 '10 lines
DIM PRT$(NUMLINES%) 'Declare size
OPEN "SELFPRT.BAS" FOR INPUT AS #1 'Open self
FOR I=1 TO NUMLINES% 'Do this til the end of the file
INPUT #1, PRT$(I) 'Add it to the contents
NEXT I 'Do it again
CLOSE 'Close self
FOR J=1 TO I 'Start outputing file
PRINT PRT$(I) 'Output file
NEXT 'Do it again
Edited on February 9, 2004, 1:32 pm