How do you write a program which produces its own source
code as its output?

Answer Posted / vivek

printitself.c

#include <stdio.h>

int main()
{

char ch;
FILE *file;

file=fopen("printitself.c","r");

while((ch=fgetc(file))!=EOF)
printf("%c",ch);

return 0;
}

Is This Answer Correct ?    19 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures

943


Explain bitwise shift operators?

927


What is a program flowchart and explain how does it help in writing a program?

984


Write a program to print numbers from 1 to 100 without using loop in c?

867


Can two or more operators such as and be combined in a single line of program code?

1122


How does selection sort work in c?

815


What is the maximum no. of arguments that can be given in a command line in C.?

897


Write a program to show the change in position of a cursor using c

834


Explain how many levels deep can include files be nested?

840


What is a stream?

884


Give basis knowledge of web designing ...

1786


Is it possible to pass an entire structure to functions?

778


What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

1585


Write the syntax and purpose of a switch statement in C.

859


Write a program to check palindrome number in c programming?

789