1. Engineering
  2. Computer Science
  3. develop c programing language and here i attached program and...

Question: develop c programing language and here i attached program and...

Question details

develop c programing language and here I attached program and give me screenshort of output for this program

  1. Develop a program that accepts integers from command line and uses fork() to have 4 child processes that will do sorting the quick sort, computing the sum of the integers, and counting the number of even numbers and the number of odd numbers respectively.

/*Template for program */

/*After conversion of string integers to real integers,
do the follows so that there are 4 child processes.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int
main(int argc, char * argv[])
{
int i=0, data[argc-1], Sum=0, EvenCount=0, OddCount=0;
for (i=1; i<argc; i++) /*convert strings to integers*/
data[i-1] = atoi(argv[i]);

   switch(fork())
   { case -1:
       break;
   case 0: /*1st child process*/

       /*here for sorting*/

       exit(1);
   default:
       switch(fork())
       { case -1:
           break;
       case 0: /*2nd child process*/

           /*here for summing*/

           exit(2);
       default:
           switch(fork())
           { case -1:
                   break;
               case 0: /*3rd child process*/

                   /*here for counting even*/

                   exit(3);
               default:
                   switch(fork())
                   { case -1:
                       break;
                   case 0: /*4th child process*/

                       /*here for counting odd*/

                       exit(4);
                   default:
                       break:
                   }
           }
       }
   }
}

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution