Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


write a C program to print the program itself ?!

Answers were Sorted based on User's Feedback



write a C program to print the program itself ?!..

Answer / vara

Most simplest ....

char *p="char *p=%s int main(){ printf(p,p);getchar();}";int
main(){ printf(p,p);getchar();}

Is This Answer Correct ?    0 Yes 4 No

write a C program to print the program itself ?!..

Answer / moumita chatterjee

#include<stdio.h>
#include<conio.h>
int main()
{
FILE *fp;
char c;
fp=fopen("G:\\selfpro.c","r");
if(fp==NULL)
{
puts("File can open");
exit(1);
}
while(1)
{
c=fgetc(fp);
if(c==EOF)
break;
else
printf("%c",c);
}
getch();
return 0;
}

Is This Answer Correct ?    0 Yes 4 No

write a C program to print the program itself ?!..

Answer / prasanna kumar s

#include<stdio.h>
#include<conio.h>

void main()
{

clrscr();
printf("welcome 2 c language");
getch();

}

Is This Answer Correct ?    0 Yes 5 No

write a C program to print the program itself ?!..

Answer / jaroosh

The most simple possible program printing itself on windows :
main()
{
char path[255];
sprintf(path,"cmd.exe /c type \"%s\"",__FILE__);
system(path);
}

on Unix you just use "cat" instead of "type" and necessary
fun to call bash command from c program.

Is This Answer Correct ?    17 Yes 23 No

write a C program to print the program itself ?!..

Answer / sriram

#include<iostream.h>
#include<conio.hg>
int main()
{
clrscr();
printf(" \t hi this is sriram \t \n");
getch();
return 0;
}

Is This Answer Correct ?    4 Yes 93 No

write a C program to print the program itself ?!..

Answer / abiraj1030&yahoo.com

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("hai");
getch();
}

Is This Answer Correct ?    10 Yes 112 No

Post New Answer

More C Interview Questions

what is linkage error when it occurs in c program

3 Answers  


12344321 123 321 12 21 1 1 how i print this program??

5 Answers   DSR Management, Winit,


What is the difference between malloc calloc and realloc in c?

0 Answers  


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

0 Answers  


#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } Find the output

5 Answers   CitiGroup,


What is an lvalue and an rvalue?

1 Answers  


What is cohesion and coupling in c?

0 Answers  


what does the following code do? fn(int n,int p,int r) { static int a=p; switch(n){ case 4:a+=a*r; case 3:a+=a*r; case 2:a+=a*r; case 1:a+=a*r; } } a.computes simple interest for one year b.computes amount on compound interest for 1 to 4 years c.computes simple interest for four year d.computes compound interst for 1 year

7 Answers   TCS,


How can a string be converted to a number?

0 Answers  


How can type-insensitive macros be created?

0 Answers  


whats the use of header file in c?

2 Answers  


Without Computer networks, Computers will be half the use. Comment.

0 Answers  


Categories