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
Is c pass by value or reference?
Tell me when is a void pointer used?
An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array
What are the 5 organizational structures?
What is a shell structure examples?
Write a program to print all permutations of a given string.
What is a newline escape sequence?
In a byte, what is the maximum decimal number that you can accommodate?
#include
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
What is a pointer in c?
How can I invoke another program (a standalone executable, or an operating system command) from within a c program?
Explain what does the format %10.2 mean when included in a printf statement?
Explain goto?
What is the default value of local and global variables in c?