i need a c program that will do this dont copy other people
i need a c program that will do this. dont copy other people work, and past it as the answor
Write a function is_palindrome0 embedded in a program, that takes a pointer to the beginning of a string and returns a boolean value. That value is true if the string is a palindrome, false otherwise. The program is supposed to get a string from the user and pass it to the function. You can use gets0 to accomplish this, or, alternatively and more secure, fgets0. A call to fgets0 would look something like that fgets(string, 80, stdin); Be aware though that this function includes the newline character at the end of the string, which you will want to remove. Hand in the C program file, commented *abundantly*. Grading Guide The program needs to run, otherwise zero points Overall correct program structure, indentations and comments no extra points, but up to 10 points will be eliminated, if *any* of those is significantly neglected. The correct coding of the program\'s parts: ° The correct driver program to take user input, call the palindrome function and output a result (palindrome or not),(10 points) If the above fgets was used the driver needs to eliminate the extra newline character-that should not be done in the functi on itself. will need to make fgets0 mandatory in the future, so for now let\'s not take off points if there are confusions related to that. ° In the function, the correct computation of the length of the string. (20 points) ° The correct loop that narrows down from both of the string\'s ends character by character to find a difference or meet in the middle with no difference. (70 points)Solution
#include<stdio.h>
#include<string.h>
#define MAX 20 // maximum length of string
int main()
{
//declare function prototype and char array and integer to hold input, return value
int is_palindrome(char *s);
char str[MAX],ret;
printf(\"Enter the string = \");
fgets(str,MAX,stdin);
str[strlen(str)-1] = \'\\0\';
printf(\"str = %s andlen=%d\ \",str,strlen(str));
//call the function
ret = is_palindrome(str);
if( ret == true)
printf(\"string %s is palindrome\ \",str);
else if( ret == false)
{
printf(\"string %s is not palindrome\ \",str);
}
}
//funcn definition
int is_palindrome(char *s)
{
int i,j=0;
char buf[MAX];
for(i = strlen(s)-1 ; i >= 0;i--)
{
buf[j++] = s[i] ;
}
buf[j]=\'\\0\';
if( strcmp(buf,s) == 0)
return true;
else
return false;
}
