Write a program in C to check whether a user given number is Palindrome or Not. code example

Example 1: Write a program to check whether inputted string is palindrome or not.

#include <stdio.h>
#include <string.h>
 
int main()
{
    char s[1000];  
    int i,n,c=0;
 
    printf("Enter  the string : ");
    gets(s);
    n=strlen(s);
 
    for(i=0;i<n/2;i++)  
    {
    	if(s[i]==s[n-i-1])
    	c++;
 
 	}
 	if(c==i)
 	    printf("string is palindrome");
    else
        printf("string is not palindrome");
 
 	 
     
    return 0;
}

Example 2: Write a C program to check whether the string is a palindrome without using string functions.

#include <stdio.h>#include <string.h> int main(){   char text[100];   int begin, middle, end, length = 0;    gets(text);    while ( text[length] != '\0' )      length++;    end = length - 1;   middle = length/2;    for( begin = 0 ; begin < middle ; begin++ )   {      if ( text[begin] != text[end] )      {         printf("Not a palindrome.\n");         break;      }      end--;   }   if( begin == middle )      printf("Palindrome.\n");    return 0;}