img
Question:
Published on: 21 November, 2024

Write a C- Program To Determine If The Given String Is A Palindrome Or Not.

Answer:

 

#include <stdio.h> 
#include <conio.h>

main()
{
     int i,n,j,len=0; 
     char str[30]; 
     clrscr();

     printf("\n Enter String:"); 
     gets(str);
    
     for(i=0;str[i]!='\0';i++)
         len++;
      printf("\n The length of the string is %d",len); 
      
      for(i=0,j=len-1;str[i]!='\0';i++,j--)
      {
          if(str[i]!=str[j])
          {
               printf("\n :The given string is not a palindrome:"); 
               getch();
               exit(0);
          }
      }
      printf("\n :the given string is palindrome:"); 
      getch();
}

Random questions