write a program wch produces its own source code aas its
output?



write a program wch produces its own source code aas its output?..

Answer / guest

#include <stdio.h>

int main(int argc, char** argv)
{
/* This macro B will expand to its argument, followed by a
printf
command that prints the macro invocation as a literal
string */
#define B(x) x; printf(" B(" #x ")\n");

/* This macro A will expand to a printf command that prints
the
macro invocation, followed by the macro argument itself. */
#define A(x) printf(" A(" #x ")\n"); x;

/* Now we call B on a command to print the text of the
program
up to this point. It will execute the command, and then
cause
itself to be printed. */
B(printf("#include <stdio.h>\n\nint main(int argc, char**
argv)\n{\n/*
This macro B will expand to its argument, followed by a
printf\n
command that prints the macro invocation as a literal
string
*/\n#define B(x) x; printf(\" B(\" #x \")\\n\");\n\n/*
This macro
A will expand to a printf command that prints the\n
macro invocation, followed by the macro argument itself.
*/\n#define A(x)
printf(\" A(\" #x \")\\n\"); x;\n\n/* Now we call B on
a command
to print the text of the program\n up to this point. It
will execute
the command, and then cause\n itself to be printed.
*/\n"))
A(printf("/* Lastly, we call A on a command to print the
remainder
of the program;\n it will cause itself to be printed,
and then
execute the command. */\n}\n"))
/* Lastly, we call A on a command to print the remainder of
the program;
it will cause itself to be printed, and then execute the
command. */
}

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More C Interview Questions

Write a program in c to print * * * * * *******

1 Answers  


what is the difference between entry control and exit control statement?

12 Answers   Darbari Lal DAV Model School,


How old is c programming language?

0 Answers  


Is it better to bitshift a value than to multiply by 2?

0 Answers  


can we declare a function in side the structure?

2 Answers   HCL,






List some of the dynamic data structures in C?

0 Answers  


What language is c written?

0 Answers  


what r the cpu registers r ther?

1 Answers  


main() { int a=4,b=2; a=b<<a + b>>2; printf("%d", a); }

4 Answers   CTS,


what is the code to display color fonts in the output?

1 Answers  


What is a union?

0 Answers  


How we add our function in liabrary as liabrary function. Exp. we want use our int factorical(int); function as int pow(int,int); function working in math header file.

1 Answers  


Categories