C program to display its own source code as output

PROGRAM:



#include <stdio.h>
int main()
 {
    FILE *fp;
    char c;
    fp = fopen(__FILE__,"r");
    do 
      {
         c = getc(fp);
         putchar(c);
       }
    while(c != EOF);
    fclose(fp);
    return 0;
}

MASTER OTHER EXAMPLES: