A quine is a program which prints a copy of its own as the only output. 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.
To the best of our knowledge, below is the shortest quine in C.
main() { char *s="main() { char *s=%c%s%c; printf(s,34,s,34); }"; printf(s,34,s,34); } |
This program uses the printf function without including its corresponding header (#include
Following is a shorter version of the above program suggested by Narendra.
main(a){printf(a="main(a){printf(a=%c%s%c,34,a,34);}",34,a,34);} |
If you find a shorter C quine or you want to share quine in other programming languages, then please do write in the comment section.
Source:
http://en.wikipedia.org/wiki/Quine_%28computing%29
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- C program to detect tokens in a C program
- C program to print a string without any quote (singe or double) in the program
- Hello World Program : First program while learning Programming
- Program for Sum of the digits of a given number
- Write a C program to print "Geeks for Geeks" without using a semicolon
- Output of the program | Dereference, Reference, Dereference, Reference....
- Program to compute Log n
- Output of C++ Program | Set 10
- Output of C++ Program | Set 14
- Output of C++ Program | Set 16
- Output of C++ Program | Set 18
- Program to print last 10 lines
- Write a C program that does not terminate when Ctrl+C is pressed
- Write a C program that won't compile in C++
- Write a program that produces different results in C and C++
- OpenCV C++ Program to play a video
- OpenCV C++ Program to blur a Video
- OpenCV C++ Program to create a single colored blank image
- OpenCV C++ Program to blur an image
- OpenCV C++ Program for coin detection

