#include <stdio.h> #include <string.h> void ReverseArray(char* apples); int main
ID: 3651170 • Letter: #
Question
#include <stdio.h>#include <string.h>
void ReverseArray(char* apples);
int main()
{
int i;
char tires[80];
strcpy(tires,"Whitewalls are best");
printf ("Tires is located at %p ",tires);
for (i=0; i<10; i++)
{
printf ("Tires[%d] = %c at %p ",i,tires[i], &tires[i]);
//printf ("Tires[%d] = %d at %p ",i,tires[i], &tires[i]);
//printf ("Tires[%d] = %c at %p ",i,*(tires+i), tires+i);
}
ReverseArray(tires);
printf("The return string is: %s ",tires);
return 0;
}
void ReverseArray(char* apples)
{
int i,j, length=0;
char temp;
length = strlen(apples);
printf("found length =%d ",length);
for(i=0, j=length-1; i<j; i++, j--)
{
temp = apples[i];
apples[i] = apples[j];
apples[j] = temp;
// printf("i=%d ",i);
}
return;
}
Explanation / Answer
#include //standard in/output lib #include //string lib void ReverseArray(char* apples);//prototype for fxn int main()//main { int i;//declare integer char tires[80];//declare char array of length 80 strcpy(tires,"Whitewalls are best");//copy string into tires variable printf ("Tires is located at %p ",tires);//print to console, where %p is address for (i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.