What is ” Quine ” in programming ?

Answer :-

Quine is basically known as – “A Self-reproducing program”, means a computer program which prints its own coding.This sounds impossible. But it is possible. This is because of some nice properties of programming.it is a consequence of the general so-called “fixed-point” theorem.
A quine takes no input. Quines are named after the American mathematician and logician Willard Van Orman Quine (1908–2000). The interesting thing is you are not allowed to use open and then print file of the program.Quines are actually quite cool. You should learn to write them. They make you think about levels of meaning — about values and their representations.

Here a C code have a look:-

<br />#include <cstdio>
// C-Quine
int main() {
char *s = "#include <cstdio>%c// C-Quine%cint main() {%c char *s = %c%s%c;%c printf(s, 0x0a, 0x0a, 0x0a, 0x22, s, 0x22, 0x0a, 0x0a, 0x0a);%c return 1;%c};";
printf(s, 0x0a, 0x0a, 0x0a, 0x22, s, 0x22, 0x0a, 0x0a, 0x0a);
return 1;
};

Output:-

Quine

The main purpose of interview questions about quine programs is usually to see whether you’ve come across them before. They are almost never useful in any other sense.

Leave a comment