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 |
Is struct oop?
could u able to tell about suresoft technical session
write a program to fined second smallest and largest element in a given series of elements (without sorting)
How does the assert() function work?
how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?
what is out put of the following code? #include class Base { Base() { cout<<"constructor base"; } ~Base() { cout<<"destructor base"; } } class Derived:public Base { Derived() { cout<<"constructor derived"; } ~Derived() { cout<<"destructor derived"; } } void main() { Base *var=new Derived(); delete var; }
I have one doubt. What does below statement mean? #define sizeof(operator) where operator can be int or float etc. Does this statement meaningful and where it can be used?
Why preprocessor should come before source code?
You have an array of n integers, randomly ordered with value 1 to n-1.The array is such that there is only one and one value occurred twice. How will you find this number?
What is the size of structure in c?
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
In C language what is a 'dangling pointer'?