Is it possible to write a program which when executed prints itself as the output?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 Is it possible to write a program which when executed prints itself
as the output?
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 For Example:
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 If my program is
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px

<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 public sub PrintMethodItself()
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 {
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 // some coding to print....
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 }
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px

<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 my expected output is:
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 public sub PrintMethodItself()
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 {
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 // some coding to print....
<p style="border:none; font-family:Segoe UI,Lucida Grande,Verdana,Arial,Helvetica,sans-serif; padding-right:0px; color:#333333; font-size:13px; line-height:16px
<span style="border:0px; font-style:inherit; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; margin:0px; outline:0px; padding:0px; line-height:normal; background-color:#f1f1f1 }

View the full article
 
Back
Top