1 Name this program reversecThis program prints all the comm

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.

Solution

void reverse(char[] str)
{
int i=0,j=0,temp=0;

j=strlen(str)-1;

while(i<j)
{
temp = str[i];
str[i] = str[j];
str[j] = temp;
i++;
j--;
}

printf(\"Reverse of the string is:%s\",str) ;

}

------------------------------------------
void reverse(char* str)
{
int i=0,j=0;

j=strlen(str)-1;
printf(\"Reverse of the string is:\");
for(i=j;i>=0;i--)
printf(\"%c\",*(s+i));
}


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site