Write C program that will fork a new process The process has
Write C program that will fork a new process. The process has to sort in ascending order an array compounded of 6 element delivered by the user, while the child process have to sort the same array in descending order. In either case your array should be displayed in the screen using shared code. (means one code to do this).
Solution
#include<stdio.h>
#include<conio.h>
void sort(int*,int);
void main()
{
int a[10];
int i,n;
clrscr();
printf(\"how many numbers u want to enter in 1st array :
\");
scanf(\"%d\",&n);
printf(\"enter numbers :\ \");
for(i=0;i<n;i++)
scanf(\"%d\",&a[i]);
sort(a,n);
for(i=0;i<n;i++)
printf(\"%d\",a[i]);
getch();
}
void sort(int *a,int m)
{
int i,j,temp;
for(i=0;i<m-1;i++)
{
for(j=i+1;j<m;j++)
{
if(a[i]>a[j])
{
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
}
}

