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

Create a directory called 1ab7 using mkdir lab7. Move into that directory and wr

ID: 3734720 • Letter: C

Question

Create a directory called 1ab7 using mkdir lab7. Move into that directory and write the following problem nnts man The main program and a sample execution are shown below. The program must use a function to reverse the arguments. l#include #include void reverse (char) int main (int arge, char *argv[]) ( for (int a-l acargc: a++) ( printf ("%s becomes ", argv[a]); reverse (argv[a]) printf ("%s ", argv [a]); return 0 1 /a.out University of Alabama Crimson Tide University becomes ytisrevinu of becomes fo Alabama becomes amabalA Crimson becomes nosmirc Tide becomes ediT

Explanation / Answer

// Code for Reverse of the string (reverse.c)

#include<stdio.h>
#include<string.h>

// Function to reverse a string
void * reverse(char * str )
{
   int i, len ;
  
   // calculating length of the string
   len = strlen(str);
  
   for( i=len ; i>=0 ; i--)
   // *(str+i) is the character at the ith index of the string
       printf( "%c", *(str+i));
}


int main(int argc,char *argv[])
{  
int a;
for(a=1;a<argc;a++){
      printf(" %s becomes ",argv[a]);
      reverse(argv[a]);
}
printf(" ");  
return(0);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote