Question: Write a program that takes three integer values as command line inputs : a number of rows (numRows), a number of columns (numColumns), and arrayMax.

Write a program that takes three integer values ascommand line inputs: a number of rows (numRows), a number of columns (numColumns), and arrayMax. You will create a 2D array with numRows rows and numColumns columns. The values in the array will be between -arrayMax and +arrayMax.

DO NOT USE "cin" in any way. Your program should utilize the command line arguments as the *only* input.

Problem B: Random Array

Your program should create a space-delimited array with the number of rows and columns as specified by numRows and numColumns and store it in an output file "randArray.txt" in the same directory as the program. The values in this array should be random numbers between -arrayMax and +arrayMax, inclusive. Your program must check if the right number of command line inputs have been provided. If not, print to the terminal an appropriate error message and exit your program with a return value >0. The program should end each row with a newline.

Note that you do not actually need to store the array in your code. You are simply generating a series of numbers and printing them to the output file.

Example Output

$ ./rand-array 2 3 0

$ cat ./randArray.txt

0 0 0

0 0 0

$ ./rand-array 4 4 8

$ cat ./randArray.txt

-1 4 -2 -3

1 6 -8 2

6 -4 -4 -6

2 8 -2 -2

PLEASE CODE IN C++! I WILL LEAVE REVIEW

THANKS!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!