answersLogoWhite

0

// Palindrome.C : A palindrome is a string that is spelled the same way forward and backward.

// This code verifies the string entered IGNORING CAPITALIZATIONS, SPACES and PUNCTUATIONS.

// Most of the CRT library functions used are with security enhancements optimized for MS Visual C++ [2010].

// For convenience, remove the "/*.*/" during coding. Same with others, I'm using this to emphasize spacing.

// Removing this does not affect the flow of the program (since /**/ is designed for comment only.)

#include <ctype.h>

#include <conio.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define SIZE 0x80 // hex for 128.

int main(void)

{

/**/ char *strsrc=(char*)calloc(SIZE,sizeof(char)),*strver=(char*)calloc(SIZE,sizeof(char));

/**/ register size_t count,counter; bool ver;

/**/ printf_s("Enter String: "); gets_s(strsrc,SIZE);

/**/ for(count=0,counter=0;count<strlen(strsrc)+1;count++)

/*.....*/ isspace(*(strsrc+count))ispunct(*(strsrc+count))?true:*(strver+counter++)=tolower(*(strsrc+count));

/**/ for(count=0,counter=strlen(strver)-1;count<strlen(strver);count++,counter--)

/*.....*/ *(strver+counter)==*(strver+count)?ver=true:ver=false;

/**/ printf_s("%s %s a palindrome.",strsrc,ver?"is":"is not");

/**/ _getch(); free(strsrc); free(strver); return 0;

}

// It is suggested to use MS Visual C++. Otherwise, remove "_s" in function names and comply with the

// appropriate passing parameters and other codings for other compilers.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is the palindrome in c language?

Nothing.


What is pallendrome in java?

palindrome in every language means same. it means on reversing a number or string, if we get the same number or string as the case may be ,then the number or string is called palindrome. eg: 1221,111,252 or LIRIL,MADAM etc .


Program to check that given string is palindrome or not in C?

/*To check whether a string is palindrome*/includeincludevoid main () { int i,j,f=0; char a[10]; clrscr (); gets(a); for (i=0;a[i]!='\0';i++) { } i--; for (j=0;a[j]!='\0';j++,i--) { if (a[i]!=a[j]) f=1; } if (f==0) printf("string is palindrome"); else printf("string is not palindrome"); getch (); }


What is meaning palindorme in C language?

The arrangement of characters from left to right in the string is the same as the arrangement of characters from right to left. e.g. MOM is a palindrome as it is same even if you read it from either left to right or right to left. while CAT is not a palindrome.


Stack c language program of palindrome?

what ever you assume


How do you determine if a given string is palindrome or not?

Reverse the string and compare it to the original. If they match, then it is a palindrome.


Prpogram in c to check the string is palindrom or not?

Here is a simple C program to check if a string is a palindrome: #include &lt;stdio.h&gt; #include &lt;string.h&gt; int main() { char str[100], rev[100]; printf(&quot;Enter a string: &quot;); fgets(str, sizeof(str), stdin); str[strcspn(str, &quot;\n&quot;)] = 0; // Remove newline character strcpy(rev, str); strrev(rev); // Reverse the string if (strcmp(str, rev) == 0) printf(&quot;The string is a palindrome.\n&quot;); else printf(&quot;The string is not a palindrome.\n&quot;); return 0; } This program takes a string input, reverses it, and then compares the original string with the reversed string to determine if it is a palindrome.


Program to find palindrome using C programming?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;string.h&gt; void main() { char a[15],b[15]; printf("Enter the string\n"); scanf("%s",&amp;a); strcpy(b,a); strrev(a); if(strcmp(a,b)==0) printf("The String is a palindrome"); else printf("The String is not a palindrome"); }


What is literal in c language?

a string constant


Shell script in unix to check if a string is a palindrome?

len=0 i=1 echo -n "Enter a String: " read str len=`echo $str | wc -c` len=`expr $len - 1` halfLen=`expr $len / 2` while [ $i -le $halfLen ] do c1=`echo $str|cut -c$i` c2=`echo $str|cut -c$len` if [ $c1 != $c2 ] ; then echo "string is not palindrome" exit fi i=`expr $i + 1` len=`expr $len - 1` done echo "String is Palindrome"


Shell script to check if a string is a palindrome?

len=0i=1echo -n "Enter a String: "read strlen=`echo $str | wc -c`len=`expr $len - 1`halfLen=`expr $len / 2`while [ $i -le $halfLen ]doc1=`echo $str|cut -c$i`c2=`echo $str|cut -c$len`if [ $c1 != $c2 ] ; thenecho "string is not palindrome"exitfii=`expr $i + 1`len=`expr $len - 1`doneecho "String is Palindrome"


How do you write programs for String Reversal Palindrome check?

Copy and reverse the string. If the reversed string is equal to the original string, the string is a palindrome, otherwise it is not. When working with strings that hold natural language phrases (including punctuation, whitespace and so on) we must remove all the non-alphanumerics and convert the remainder to a common case, such as lower-case, prior to copying and reversing the string.