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 |
Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.
How to add two numbers without using arithmetic operators?
18 Answers College School Exams Tests, e track, Infosys, Pan Parag, Sapient, TCS,
what is the use of call back function in c?tell me with example
Mention four important string handling functions in c languages .
Switch (i) i=1; case 1 i++; case 2 ++i; break; case 3 --i; Output of i after executing the program
main() { printf("\n %d %d %d",sizeof('3'),sizeof("3"),sizeof(3)); }
What is the role of this pointer?
Why do we use main function?
Without Computer networks, Computers will be half the use. Comment.
what is develop in c language
Differentiate between declaring a variable and defining a variable?
What is a method in c?