Nov
13
2012

Self producing programs or Quines

A Quine is a computer program which prints out it’s own source code . It is named after Willard Van Orman Quine, an american mathematician and logician. The idea here is, we will be having two parts of source code like any other programs. Namely code and data. Code is the set of instructions which are going to be executed by compiler, and data part contains textual form of code inside quotation mark. Code part executes to print data part, which is nothing but code itself. To make it more clear lets see an example in c++

Language: C++
Author: lapinski@utexas.edu
#include
main(){char*s="#include%cmain(){char*s=%c%s%c;cout.form(s,10,34,s,34,10);}%c";cout.form(s,10,34,s,34,10);}</pre>
<div></div>
<pre>

This concept can be extended to multiple levels. 
They are known as ouroboros programs.
For more info visit : 
http://www.madore.org/~david/computers/quine.html

Related Posts

About the Author:

Leave a comment