Child Process Using Fork() System Call And Check Given Number Is Odd Or Even

C program to create child process using fork () system call and check given number is odd or even. Source Code: #include<stdio.h> #include<time.h> #include<stdlib.h> void main() { int id,n; printf("Enter the number: "); scanf("%d",&n); id=fork(); if(id == 0) { if(n % 2 != 0) printf("\nIt is an odd number.. from child process"); } else { if(n % 2 == 0) printf("\nIt is an even number.. from parent process"); } }

Share:

0 comments