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 ?!

Answer Posted / neenu jacob

#include <stdio.h>

main()
{
int pid,ppid;
int q=getpid();
int gid,egid,uid,euid;
int f=fork();
if (f==0)
{
printf("hai\n%d\n%d\n%d",getuid(),geteuid());

}
else
{
pid=getpid();
ppid=getppid();
printf("%d\n%d\n%d\n%d",pid,ppid,q,f);
}
system("cat /home/mec/lab1.c");
}

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can two or more operators such as and be combined in a single line of program code?

1382


Differentiate call by value and call by reference?

986


What is the difference between formatted&unformatted i/o functions?

1066


What are control structures? What are the different types?

1102


Why do we write return 0 in c?

1084


If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402

3933


What are the properties of union in c?

1063


Why is void main used?

1107


What does s c mean on snapchat?

1126


How can you invoke another program from within a C program?

1084


Describe newline escape sequence with a sample program?

1133


Explain how can you restore a redirected standard stream?

1111


Explain why C language is procedural?

1233


How do you define a string?

1114


regarding pointers concept

2052