Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Recall that a geometric sequence is a sequence of numbers where each term is the previous term multiplied by a constant r, and
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
answer 1 include include int main int anri printfEnter the values of nar scanfdddnar fori 1 i 100 co...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started