Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 (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
Step: 1
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