solve c programing language with Output screeshort?
Develop a program that
accepts integers from command line and uses fork() to
have 4 child processes that will do sorting the integers into
ascending order,
computing the sum of the integers, and counting the number
of even numbers and the number of odd numbers respectively.
Answer:
c code:
#include <stdio.h>
#include<unistd.h>
int main()
{
int n;
printf("Enter the n value ");
scanf("%d",&n);
//Reading number of integers
printf("Enter the values into the array
");
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",a[i]);
//Reading integers into the array
}
n1=fork();
n2=fork();
if(n1==0 && n2>0)
{
int tmp=0;
for(int
i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
tmp=a[i];
a[i]=a[j];
//main process executing and sorting in ascending order
a[j]=tmp;
}
}
}
printf("sorted in
Ascending order");
for(int
i=0;i<n;i++)
printf("%d
",a[i]);
}
else if(n1>0 && n2==0)
{
int sum=0;
for(int
i=0;i<n;i++)
sum+=a[i];
//child process 1 executing and computing sum of integers
printf("sum is
%d",sum);
}
else if(n1==0 && n2==0)
{
int eve=0;
for(int
i=0;i<n;i++)
{
if(a[i]%2==0)
//child process 2 executing and counting even integers
eve++;
}
printf("Number of even
integers are %d",eve);
}
else if(n1>0 && n2>0)
{
int odd=0;
for(int
i=0;i<n;i++)
{
if(a[i]%2!=0)
//child process 3 executing and counting odd integers
odd++;
}
printf("Number of odd
integers are %d",odd);
}
return 0;
}
Execution screenshots:



Note: please like the answer if you are satisfied with it. Thank you in advance.
solve c programing language with Output screeshort? Develop a program that accepts integers from command line...
Develop c program and give me screenshot of output? Develop a program that accepts integers from command line and uses fork() to have 4 child processes that will do sorting the integers into ascending order, computing the sum of the integers, and counting the number .of even numbers and the number of odd numbers respectively.
Develop c program and give me screenshot of output? Develop a program that accepts integers from command line and uses fork() to have 4 child processes that will do sorting the integers into ascending order, computing the sum of the integers, and counting the number .of even numbers and the number of odd numbers respectively
Develop a program that accepts integers from command line, sorts the integers into ascending order, computes the sum of the integers, and counts the number of even numbers and the number of odd numbers. Solve in C programing language?
Write a C or C++ program A8p1.c(pp) that accepts one command line string parameter. Call the fork function to produce two processes. In the child process print out the lower case version of the string. In the parent process print out the reversed upper case version of the string (e.g. child: “abc”; parent: ”CBA”). You may call the toupper and tolower functions in the header <ctype.h> if you wish. Specify in the output whether the parent or child process is...
Command Line Arguments: Write a program in C Compiler that will accept two integers on command line, subtract the second from the first (1st - 2nd) and display the answer. It exactly two numbers are not provided on command line, there should be a simple error message printed and the program ends with no further input, output, or calculations
Write a program that will accept two integers on command line, use the swap subprogram to swap them, and then print the two numbers out. For example, I enter a.out 10 15 and the output that would print is 15 10. Please note that if exactly two numbers are not provided on command line, your program should display an error message and end with no further action. The programming language is C Compiler.
2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum of both of the integers and all the numbers in between Write a Marie program that determines the largest of a series of positive integers provided by a user. The user will enter a -1 when she is finished. Up to 10 numbers will be provided by the user. Write a Marie program that accepts two positive integers, multiples them by repeated addition, and...
WRITE A PROGRAM IN C++ THAT DECLARES AN INTEGER VECTOR V 1.)INITIALIZE THE VECTOR, V, WITH 10 INTEGERS WITH VALUES FROM 1 TO 10 2.)OUTPUT THE VECTOR IN DESCENDING ORDER, THEN ASCENDING ORDER 2.)ADD ALL THE EVEN NUMBERS 3.)ADD ALL THE ODD NUMBERS 4.)OUTPUT THE SUM OF EVEN INTEGERS 5.)OUTPUT THE SUM OF ODD INTEGERS 7.)OUTPUT THE PRODUCT OF EVEN INTEGERS 8.)OUTPUT THE PRODUCT OF ODD INTEGERS SAMPLE: Vector: 2 4 3 5 2 3 8 9 1 10 Ascending...
Write a program that uses command-line processing to get a number of integers and then print them out in descending order. The number of input integers is limited to 5 ; otherwise, an error message should be displayed. A sample output is shown below:I still cant figure out how to do the c++ command line assignment on visual studios so help me with the full coding asap.Keep in mind the program should be a beginner's level and dont make it...
Assignment: Using the Fork System Call The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorthm: n={n / 2 , if n is even 3 * n + 1 , if n is odd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1. For example, if n = 35, the sequence is: 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2,...