Complete the following C function. The function has a parameter, which is a poin
ID: 3570093 • Letter: C
Question
Complete the following C function. The function has a parameter, which is a pointer to a string. The function should return the value 1 if string is a palindrome, i.e the same sequence of characters forwards and backwards e.g, "abcba". " able was I ere I saw elba", or "! OttO .!". If the string is not a palindrome the function should return the value 0. The string should be considered case-sensitive.
in isPalidrome(const char * string) {
int length = strlen(string);
for (int i = 0; i < length / 2; i++)
/*fill in missing line here *?
return 0;
return 1;
}
Explanation / Answer
in isPalidrome(const char * string) {
int length = strlen(string);
for (int i = 0; i < length / 2; i++)
{ if(string[i]!=string[length-i-1])
return 0;
}
return 1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.