Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Having trouble writing this small program: C Program (program written in C language) should: - Generate set of integer arrays that are randomly populated using

Having trouble writing this small program:

C Program (program written in C language) should:

- Generate set of integer arrays that are randomly populated using command line arguments below (ex. main( intargc, char *argv[]) (note: number of values in each array may be different) -q Number of queues (default: 1) -r Total number of requests (default: 5) (you can also think of it as number of total # of integers randomly distributed to each queue. explained in example below) -min Minimum integer value (default: 0) -max Maximum integer value (default: 20)

After filling all the queues, the program should print out the sum for each queue and the values in the queue with the lowest sum.

Example, if the command line is program q 2, the output might be:

Queue 1 sum: 29 Queue 2 sum: 34 Values in lowest-sum queue: 14, 5, 10

note: Since -r by default is 5, Queue 1 has 3 integers (we know it's queue 1 because lowest-sum equals 29), which means Queue 2 only has 2 integers, equaling 5 total integers. Those integers are randomly distributed. You could end up with queues with no integers and you could end up with all queues having around the same number of integers. (tip: rand() is one way of randomizing but there are other ways)

note: Arguments will be a string that needs to be converted (hint: one way is using atoi, but there are other ways)

note: C Program should be able to execute either no "-" arguments, or all four arguments at once, or any combintion of arguments. This could be done with a switch statement or an if-else statement. Don't worry about odd cases or error checking.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the purposes of collection messages? (Objective 5)

Answered: 1 week ago