Write a C program that accepts an argument. In the following discussion, we refer to that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C program that accepts an argument. In the following discussion, we refer to that argument as the main argument. The main program must create a child. If the main argument is greater or equal to 5, then the child must call an executable file that finds the sum of numbers 1 to that main argument. Then the child must print the sum. If the argument is 0 to 4 (including 4), then the function must execute a Linux script that asks the user to enter two numbers and add the numbers and display the result. The parent process must wait for the child to finish if the main argument is not negative and then display the statement that the parent waited for the child to finish. Otherwise, the parent must not wait and display the main argument was negative. You must write the above program, the C program that the child may executes its executable and the script that the child may execute. Write a C program that accepts an argument. In the following discussion, we refer to that argument as the main argument. The main program must create a child. If the main argument is greater or equal to 5, then the child must call an executable file that finds the sum of numbers 1 to that main argument. Then the child must print the sum. If the argument is 0 to 4 (including 4), then the function must execute a Linux script that asks the user to enter two numbers and add the numbers and display the result. The parent process must wait for the child to finish if the main argument is not negative and then display the statement that the parent waited for the child to finish. Otherwise, the parent must not wait and display the main argument was negative. You must write the above program, the C program that the child may executes its executable and the script that the child may execute.
Expert Answer:
Answer rating: 100% (QA)
Below is a C program that accomplishes the described task Additionally Ill provide the childs C program and the Linux script that it may execute 1 Parent C Program parentc c include include include include int mainint argc char argv if argc 2 printfUsage s argv0 return 1 int mainArg atoiargv1 if mainArg 0 pidt childpid fork if childpid 0 perrorFork failed return 1 if childpid 0 Child process if mainArg 5 execlpsumexecutable sumexecutable argv1 NULL else execlpaddnumbersscriptsh addnumbersscriptsh NULL perrorExec failed exit1 else Parent process if mainArg 0 int status waitstatus printfParent waited for the child ... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
Write short answers of the following questions. 1. Describe Laravel MVC Framework Structure in your own words. 2. What are Grid classes in the Bootstrap? Explain jumbotron and list group in Bootstrap...
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Please do the following Matlab problem, 1.Write a for loop ranging from 3 to 5. In the loop, print the value of the loop index to the screen using fprintf in the following format: Value is n where n...
-
Your friend recently attended a local mail fraud trial. In your conversation about the case, she described the cross-examination of the expert witness as follows: After his counsels questioning was...
-
An ideal gas is kept in a container of constant volume. The pressure of the gas is also kept constant. (a) If the number of molecules in the gas is doubled, does the rms speed increase, decrease, or...
-
(a) Among 63 people at least how many were born in the same month? Answer = (b) Assuming that no one is born on Feb. 29 (leap day), how many people should be selected to guarantee that at least 9...
-
For some one-dimensional input data, construct a GP RBF covariance matrix. Use Gibbs sampling to sample functions from this GP prior (samples from a GP prior are just samples from a multivariate...
-
Raner, Harris, & Chan is a consulting firm that specializes in information systems for medical and dental clinics, The firm has two officesone in Chicago and one in Minneapolis. The firm classifies...
-
0 2 Open the Cap2 Inventory table in Design View. Rename the ID field to Item ID and change the Data Type to Short Text. Continue adding the following fields as Short Text except for Cost, whic...
-
For the base case in this section, as a percentage of sales, COGS = 70 percent, SGA = 14 percent, R&D = 2.8 percent. Depreciation, Interest expense are fixed as stated. Tax Rate is 21 percent. 1.a...
-
You are a project manager for a non-governmental organization project for improving employment opportunities for felons in a rural locality. The stakeholders are having hard time expressing their...
-
The following information is needed to reconcile the cash balance for Gourmet Catering Services. A deposit of $ 5 , 8 0 0 is in transit. Outstanding checks total $ 1 , 1 0 0 . The book balance is $ 6...
-
1. Is it fair for government to levy higher tax rates on the incomes of richer households? Why or why not? 2. What role does discrimination play in determining who is poor and the extent of poverty?...
-
Through digital connectivity, many businesses now compete on in a global market. While the principles of marketing remain the same, strategies and tactics are very dependent on each country. It is...
-
1. Knowledge of financial tools is relevant for decision making in all areas of business (be it finance, marketing, production etc.) and also in managing personal finances. The decision involves an...
-
Suppose you are trying to find the volume of a box based on thefollowing measurements for the length, width, and height of thebox, where the height was measured in two parts. length, l = 2.2 in...
-
Use these numbers for the fall season: Sales Beginning inventory GM$ August $10,500 $58,000 $5,600 September $11,900 $66,000 $6,800 October $11,000 $62,000 $5,900 November $12,600 $72,000 $7,200...
-
Refer to the table to answer the following questions. Year Nominal GDP (in billions) Total Federal Spending (in billions) Real GDP (in billions) Real Federal Spending (in billions) 2000 9,817 578...
-
Metropolitan Edison Company is a privately owned and operated Pennsylvania corporation subject to extensive regulation by the Pennsylvania Public Utility Commission. Under a provision of its general...
-
Robinson, a truck driver for a moving company, decided to buy a used truck from the company. Branch, the owner, told Robinson that the truck was being repaired and that Robinson should wait and...
-
Linda King was found liable to Charlotte Clement as the result of an automobile accident. King, who was insolvent at the time, declared bankruptcy and directed her attorney, Prestwich, to list...
-
The following information is available for Rapper Inc. - Taxable income in 2020: \(\$ 115,000\) - Accounts receivable on installment sales GAAP basis: \(\$ 150,000\) Tax basis: \(\$ 0\) - Tax rate:...
-
Cruse Corporation started operations on January 1,2020 . Taxable income from the tax return is \(\$ 2,850,000\). Income tax rate is \(25 \%\). There were no beginning balances in deferred tax...
-
For 2020, Raleigh Corporation had taxable income of \(\$ 100,000\) and an income tax rate of \(25 \%\). Raleigh had a \(\$ 75,000\) credit balance in its Deferred Tax Liability account. This credit...
Study smarter with the SolutionInn App