ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
How do you write a program which produces its own source
code as its output?
 Question Submitted By :: Tribhuvan Sharma
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How do you write a program which produces its own source code as its output?
Answer
# 1
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 ?    1 Yes 0 No
Vivek
 
  Re: How do you write a program which produces its own source code as its output?
Answer
# 2
Try to google....quine Problem...

one solution is 

main(){char *c="main(){char
*c=%c%s%c;printf(c,34,c,34);}";printf(c,34,c,34);}
 
Is This Answer Correct ?    0 Yes 0 No
Abhinav Gupta
 
 
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
n=7623 { temp=n/10; result=temp*10+ result; n=n/10 } Wipro3
main() { clrscr(); } clrscr(); ME3
what is the diff b/w static and non static variables in C. Give some examples plz. Wipro2
2.main { int x,j,k; j=k=6;x=2; x=j*k; printf("%d", x); HCL6
What's the difference between struct x1 { ... }; and typedef struct { ... } x2; ?  2
what is the value of 'i'? i=strlen("Blue")+strlen("People")/strlen("Red")-strlen("green") Cadence3
1 232 34543 4567654 can anyone tell me how to slove this c question  3
Why doesn't the code "a[i] = i++;" work?  2
what is the use of #pragma pack, wer it is used?  1
How many ways are there to swap two numbers without using temporary variable? Give the each logic.  4
N O S I E R + A S T R A L ---------------- 7 2 5 6 1 3 Honeywell1
why TCS selected more student in the software field from all institution. TCS3
consider the following structure: struct num nam{ int no; char name[25]; }; struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}}; ..... ..... printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1); What does the above statement print? a.8,9 b.9,9 c.8,8 d.8,unpredictable value TCS2
main() {char a[10]={1,2,3,4,5,6};int x; for(x=0;x<4;x++){ b[x]=x+'a';} printf("%s",b);}  3
write the program for prime numbers? TCS7
How the processor registers can be used in C ? HP4
WAP to accept basic salary of an employee? Calculate it HRA=25%,DA=30%,PF=30%&net salary display all contents?  3
What is the output of the following program #include<stdio.h> main() { int i=0; fork(); printf("%d",i++); fork(); printf("%d",i++); fork(); wait(); } ADITI2
15.what is the disadvantage of using macros? 16.what is the self-referential structure? 17.can a union be self-referenced? 18.What is a pointer? 19.What is the Lvalue and Rvalue? 20.what is the difference between these initializations? 21.Char a[]=”string”; 22.Char *p=”literal”; 23.Does *p++ increment p, or what it points to?  1
What's the difference between calloc() and malloc()?  2
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com