What is a quine in computing ?

2.15K viewsProgramming
0

 

What does the quine do ?

Changed status to publish
0

Quine is a self replicating computer program i.e it outputs it’s own source as output.

Below are a few examples of quine programs:-

Python

s='s=%r;print(s%%s)';print(s%s)

Javascript

(function a(){console.log('('+a+')()')})()

C/C++

#include <stdio.h>
int main(){
char*s="#include <stdio.h>%cint main(){%cchar*s=%c%s%c;%cprintf(s,10,10,34,s,34,10);return 0;}";
printf(s,10,10,34,s,34,10);return 0;}

Java

class Q{public static void main(String[]a){String s="class Q{public static void main(String[]a){String s=%c%s%c;System.out.printf(s,34,s,34);}}";System.out.printf(s,34,s,34);}}

The above codes can be tried on our online IDE at Golibrary IDE

Changed status to publish
Write your answer.

Categories