1. Recall that a geometric sequence is a sequence of numbers where each term is the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Recall that a geometric sequence is a sequence of numbers where each term is the previous term multiplied by a constant r, and the first term in the sequence is a constant a: {a, ar, ar?, ar, .} Suppose a = 2, r = 3, then the geometric sequence is: {2, 6, 18, 54, 162, ...} Write a program that creates a child process and generates the first n terms of this sequence in the child process. The integers n, a, and rwill be provided on the command line. For example, if the three integers 6, 2, 3 are passed as parameters on the command line, when you run your program as follows (assume your program executable is named geom): $ ./geom 6 2 3 Then the child process will output to screen: 2, 6, 18, 54, 162, 486 Do error checking to make sure that the three integers passed on the command line are all positive. 2. Write a program that takes a list of integers and creates two new threads --- one thread counts the number of integers in the list that are greater than 100; one thread takes the difference between the largest and the smallest integer in the list. The integers will be passed to the program on the command line. For example, assume your program executable is named calc and you run the program with the list of integers on the command line as shown below: $ ./calc 10 17 30 200 125 2 The program will output: The number of integers greater than 100 is 2. The difference between largest and smallest integer is 198. Declare global variables for storing the count of integers greater than 100 and for the difference between largest and smallest integer. The threads will set these values, and the parent thread will print these to screen after the child threads have finished. 1. Recall that a geometric sequence is a sequence of numbers where each term is the previous term multiplied by a constant r, and the first term in the sequence is a constant a: {a, ar, ar?, ar, .} Suppose a = 2, r = 3, then the geometric sequence is: {2, 6, 18, 54, 162, ...} Write a program that creates a child process and generates the first n terms of this sequence in the child process. The integers n, a, and rwill be provided on the command line. For example, if the three integers 6, 2, 3 are passed as parameters on the command line, when you run your program as follows (assume your program executable is named geom): $ ./geom 6 2 3 Then the child process will output to screen: 2, 6, 18, 54, 162, 486 Do error checking to make sure that the three integers passed on the command line are all positive. 2. Write a program that takes a list of integers and creates two new threads --- one thread counts the number of integers in the list that are greater than 100; one thread takes the difference between the largest and the smallest integer in the list. The integers will be passed to the program on the command line. For example, assume your program executable is named calc and you run the program with the list of integers on the command line as shown below: $ ./calc 10 17 30 200 125 2 The program will output: The number of integers greater than 100 is 2. The difference between largest and smallest integer is 198. Declare global variables for storing the count of integers greater than 100 and for the difference between largest and smallest integer. The threads will set these values, and the parent thread will print these to screen after the child threads have finished.
Expert Answer:
Answer rating: 100% (QA)
answer 1 include include int main int anri printfEnter the values of nar scanfdddnar fori 1 i 100 co... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Write a UNIX program that creates a child process that prints a greeting, sleeps for 20 seconds, then exits. The parent process should print a greeting before creating the child, and another after...
-
Write a Windows program that creates a child process that prints a greeting, sleeps for 20 seconds, then exits. The parent process should print a greeting before creating the child, and then...
-
The Fibonacci sequence is a sequence of numbers in which the first two numbers are 1 and each subsequent number is the sum of the previous two Fibonacci numbers. The sequence is 1, 1, 2, 3, 5, 8, 13,...
-
LOCATE APPROPRIATE CPT CODES ICD-10-CM (CPT) FOR PROCEDURES BELOW- Outpatient procedures only 1. INCISION AND DRAINAGE OF A CYST --- 2. DEBRIDEMENT - 3. SIMPLE REPAIR OF A SUPERFICIAL WOUND- 4....
-
An electron is accelerated from rest through a potential difference so that its de Broglie wavelength is 0.010 nm. What is the potential difference?
-
Two racquetballs are placed in a glass jar, as shown in Figure P12.62. Their centers and the point A lie on a straight line. (a) Assume that the walls are frictionless, and determine P1, P2, and P3....
-
Journalize the following adjusting entries at December 31: 1. Services provided but not recorded, $1,500. 2. Salaries earned by employees but not recorded, $2,300. 3. Accrued interest on a note...
-
Preparing a classified balance sheet Required Use the following information to prepare a classified balance sheet for Steller Co. at the end of 2012. Accounts receivable .... $42,500 Accounts payable...
-
What innovative methodologies can leaders employ to cultivate a diverse and inclusive workforce, thereby capitalizing on the manifold perspectives and experiences to foster creativity and drive...
-
Derive the system of differential equations describing the straight-line vertical motion of the coupled springs shown in Figure 7.6.6. Use the Laplace transform to solve the system when k 1 = 1, k 2...
-
39. Consider the following product structure. D (2) B(1) E (1) A C (1) F (2) D (1) F (1) If the demand for product A is 30 units, and there are 10 units of B on hand and none of C, how many units of...
-
The business was established via the receipt of $29 000 of cash and issuance of common stock to the investor. Next the business paid $2 600 in rent for the first month of operations and $14 000 of...
-
ACME produces Rocket Powered Skateboards for Wiley Coyote and friends. Direct materials cost $ 4 0 per unit, Direct labor cost $ 1 5 per unit, and factory overhead is applied based on direct labor...
-
Eagles Inc is a new start up . During their first year of operations, they agreed to provide their employees with 2 hour of vacation for every 4 0 hours worked. Vacation vests immediately ( cannot be...
-
Address one of the following topics .keep your responses brief and productive! Explain why cash flows occurring at different times must be adjusted to reflect their value as of a common date before...
-
In a creep test at 640 C, a stainless steel specimen loaded in tension at a stress of 80 MPa failed by creep rupture after 1000 hours. This same material is loaded in tension, also at 80 MPa, in an...
-
Two point charges of 61.4 C and 17.4 C exert a force of repulsion of 3 N on each other? Determine separation distance between the two charges.
-
Which of the following gives the range of y = 4 - 2 -x ? (A) (- , ) (B) (- , 4) (C) [- 4, ) (D) (- , 4] (E) All reals
-
Let f (x) = 1 / (1 - x) (a) Find the domain and range of f. (b) Find f {f (x)}. What is the domain of this function? (c) Find f {f (f (x)}. Is the graph a line? Why or why not?
-
An airplane flying at 550 miles per hour has a bearing of 52. After flying for 1.5 hours, how far north and how far east will the plane have traveled from its point of departure?
-
A car radiator contains 10 liters of a 30% antifreeze solution. How many liters should you replace with pure antifreeze to get a 50% antifreeze solution?
-
A hospitals records show that the cost of carrying out health checks in the last five accounting periods has been as follows: Using the highlow method and ignoring inflation, the estimated cost of...
-
Intermediate: Cost estimation using the linear regression formula. The management accountant at Josephine Ltd is trying to predict the quarterly total maintenance cost for a group of similar...
-
The budget for the production cost of a new product was based on the following assumptions: (i) Time for the 1 st batch of output = 10 hours (ii) Learning rate = 80 per cent (iii) Learning will cease...
Study smarter with the SolutionInn App