C Program Which Produces Own code as its Output:
This is program to produce output of its own code. In which we use FILE Pointer to produce the code as its output.
For Example:
if we write the code of helloworld. then this program is produce code as its output.


ALGORITHM:-

step 1 : Start
step 2 : Take a FILE pointer
step 3 : Open the file in Read Mode
step 4 : Putchar of the file untill EOF
step 5 : Close the file
step 6 : Stop

PROGRAM CODE:-

#include<stdio.h>
#include<conio.h>
void main()
{
    FILE *fp;
    char c;
    //Open the file pointer in read only mode
    fp = fopen(__FILE__,"r");
    do
    {
        c= getc(fp);
        putchar(c);
    }
    while(c!=EOF);

    fclose(fp);

    getch();
}

OUTPUT:-

#include<stdio.h>
#include<conio.h>
void main()
{
    FILE *fp;
    char c;
    //Open the file pointer in read only mode
    fp = fopen(__FILE__,"r");
    do
    {
        c= getc(fp);
        putchar(c);
    }
    while(c!=EOF);

    fclose(fp);

    getch();
}

C Program to produce code as its output
How to print the program code as its output
Print the program as output