Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
#include <stdio.h>
int n=2;
void main()
{
printf(" enter a positive number");
scanf("%d",&n );
if ((n%2)==0)
{
printf("the number is even");
}
else
{
printf("the number is odd");
}
}
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main()
{
int PID;
int childnum;
for(childnum=1; childnum<=3; childnum++)
{
PID=fork();
if (PID>0)
{
printf("Parent, my pid is %d: Spawned child #%d whose pid is %d\n", getpid(), childnum, PID);
}
else
{
printf("I am child #%d, my pid is %d; my parent's pid is %d\n", childnum, getpid(), getppid());
if (childnum==2)
execv("child2replacement",NULL);
childnum=10;
}
}
}