How do you write a program which produces its own source
code as its output?
Answer Posted / abhishek
#include <stdio.h>
static char prog[] = "#include <stdio.h>%c%cstatic char prog[] = %c%s%c;%c%cint main(void)%c{%c printf(prog, 10, 10, 34, prog, 34, 10, 10, 10, 10, 10, 10, 10);%c return 0;%c}%c";
int main(void)
{
printf(prog, 10, 10, 34, prog, 34, 10, 10, 10, 10, 10, 10, 10);
return 0;
}
Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
What does the error message "DGROUP exceeds 64K" mean?
Explain what is the stack?
What is a struct c#?
Is it valid to address one element beyond the end of an array?
I came across some code that puts a (void) cast before each call to printf. Why?
Is Exception handling possible in c language?
number of times a digit is present in a number
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
Compare and contrast compilers from interpreters.
5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.
Explain the difference between the local variable and global variable in c?
Explain how does flowchart help in writing a program?
List the variables are used for writing doubly linked list program.
swap 2 numbers without using third variable?