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.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?