Question: 5. Based on the program you worked on during in-class discussions (attached below), write your code to allow users to use command-line arguments to specify

 5. Based on the program you worked on during in-class discussions

5. Based on the program you worked on during in-class discussions (attached below), write your code to allow users to use command-line arguments to specify number X to be printed Y/5 times when X and Y are supplied. Make sure your check possible incorrect inputs of X and Y (including X not as a number or Y as negative or non-integer). Your source code can be written either inside Ubuntu using vi, pico, nano, etc. or in your host system then shared to Ubuntu. Run your program with different (correct and incorrect) inputs and show that your code works as needed. Take snapshots of these executions. #include #include #include 1/arg[0] stores the command itself, argy[1] stores first // argument, etc. int main(int arge, char *acgx[]) int max.num; // check number of arguments. This number includes the command if (args!= 2) { printf("Usage: %s max num (must be an integer) ", argx[0]); return 1; // convert argument string to integer max. num = atsi argx[1]); printf("maxnum=%d ", max.num); return 0

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 Databases Questions!