All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
print 'print 'print 'print ... (Posted on 2003-09-19) Difficulty: 5 of 5
Write a program that prints itself.

See The Solution Submitted by DJ    
Rating: 4.6875 (16 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 26 of 32 |
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
  Posted by Jack McBarn on 2003-11-11 11:33:02
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (10)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information