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

Here is the code I have so far. #include <stdio.h> #include <stdlib.h> #include

ID: 3594456 • Letter: H

Question

Here is the code I have so far.

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>

void reverse(char *);

int main(int argc, char *argv[]) {

for (int a=argc-1; a>=0; a--) {

reverse(argv[a]);

printf("%s" ", argv[a] );

}

return 0;

}

void reverse(char * str) {

return;

}

1. Name this program reverse.c-This program prints all the command-line arguments last argument to the first, printing each word backwards). Two sample executions are shown below /a.out Crimson Tide Alabama UA ./a.out hello world dlrow olleh tuo.a/. AU amaba1A ediT nosmirC tuo.a/. (a character Your program must use a function to reverse the arguments. This function takes a single argument string) and modifies that character string. You can write the function signature for this function in either of the ways shown below (since the name of an array is also a pointer to the start of the array). void reverse (char *) void reverse (char1) Hint - the algorithm in zyBooks 5.8 for reversing an array of integers can also be used to reverse a word.

Explanation / Answer

Below is your program: -

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>

void reverse(char *);

int main(int argc, char *argv[]) {

int a;

for (a=argc-1; a>=0; a--) {

reverse(argv[a]);

printf("%s ", argv[a] );

}

return 0;

}

void reverse(char * str) {

char *start = str;

char *end = start+strlen(str)-1;

while(start<end)

{

char temp = *end;

*end = *start;

*start=temp;

start++;

end--;

}

}