Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

GONZO CPP Write a program gonzo.cpp that takes 2 command line input arguments: a

ID: 3830165 • Letter: G

Question

GONZO CPP Write a program gonzo.cpp that takes 2 command line input arguments: a number (N) and a name. The program then does 2 things: it prints out what the remainder of N divided by 10 is and, on the next line, prints out the name N times separated by a comma and space character with a period at the end of the sentence. You are only permitted to use the iostream library and you must use a switch statement at least once in this program. A session should look exactly like the following example (including whitespace and formatting note that there is no whitespace at the end of each of these lines and each printed line has a newline at the end), with all manners of different numbers for inputs and the output: /gonzo 5 jim 5 divided by ten leaves a remainder of five. jim, jim, jim, jim, jim. ./gonzo 53 pam 53 divided by ten leaves a remainder of three. pan, pam, pam, pam, pam pam, pam, pam pam, pam pam pam, pam pam pam, pam, pam, pam, pam pam, pam, pam pam, pa m, pam, pam, pam, pam, pam, pam, pam, pam, pan, pams pam, pam, pams pam, pam, pam, pam, pam, pam, Pams pam, pam, pams pam pam pam, pam pam pam ./gonzo 20 dwight 20 divided by ten leaves a remainder of zero. dwight, dwight, dwight, dwight, dwight, dwight dwight, dwight, dwight, dwight, dwight, dwight, dwight, dwight, dwigh t, dwight, dwight, dwight, dwight, dwight. ./gonzo 18 michael 18 divided by ten leaves a remainder of eight. michael, michael, michael, michael, michael, michael, michael michael, michael, michael, michael, michael, michael michael, michael, michael, michael, michael.

Explanation / Answer

Here is the code. Scan through each argument string, reversing it, and printing the reversed value. I think it will give some idea to work on.

#include <iostream>
using namespace std;
int main(int arg, char **argv)
{
for (int i=arg; i>0; i--)
cout << argv[i-1] << " ";// reverse on each argument.
return 0;
}