C program to check whether a given string is a palindrome
kw.c
#include<stdio.h>
#include<string.h>intmain(){chars[50],reverse[50],temp;printf("———————————————————————————————————————————");printf("\nProgram to check if a string is palindrome");printf("\n———————————————————————————————————————————");printf("\nEnter the string ");scanf("%s",s);strcpy(reverse,s);for(inti=0,j=strlen(s)-1;i<j;i++,j--){temp=s[i];s[i]=s[j];s[j]=temp;}if(strcmp(s,reverse)==0){printf("String is palindrome");}else{printf("String is not palindrome");}printf("\n———————————————————————————————————————————\n");return0;}
Output
kodingwindow@kw:~$ gcc kw.c kodingwindow@kw:~$ ./a.out
———————————————————————————————————————————
Program to check if a string is palindrome
———————————————————————————————————————————
Enter the string MOM
String is palindrome
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.