Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions