How do you write a program which produces its own source
code as its output?

Answer Posted / vivek

printitself.c

#include <stdio.h>

int main()
{

char ch;
FILE *file;

file=fopen("printitself.c","r");

while((ch=fgetc(file))!=EOF)
printf("%c",ch);

return 0;
}

Is This Answer Correct ?    19 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is oops c?

881


Program will then find the largest of three numbers using nested if-else statements. User is prompted to enter three numbers. Program will find the largest number and display it on the screen. All three numbers entered by the user are also displayed. If user enters 21, 33, and 5, the output should be as follows: You entered: 21, 33 and 5. The largest number is 33.

1336


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2344


What are the valid places to have keyword “break”?

861


Why ca not I do something like this?

818


Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer

4131


Is it possible to initialize a variable at the time it was declared?

1034


how to find anagram without using string functions using only loops in c programming

2968


Explain what is a pragma?

824


What is the function of volatile in c language?

902


What is the use of a conditional inclusion statement in C?

867


What are keywords in c with examples?

859


What is anagram in c?

728


What is the difference between array and pointer in c?

837


When would you use a pointer to a function?

820