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

Write c program to print palindrome using string without using strrev strlen strcam?

sdfdg


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 (); }


How do you write a program in C to check whether a word is a palindrome or not?

It is a simple program. i think u may understand it :#include#include#includevoid main(){char s[10]=answers.com;char x[10];int a;clrscr();strcpy(x,s);strrev(s);a=strcmp(s,x);if(a==0){printf("the entered string is palindrome");}else{printf("the entered string is not palindrome");}output:given string is not 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"); }


How do you write a palindrome program in c in Wikipedia?

You don't have to write palindrome programs in wikipedia.


Stack c language program of palindrome?

what ever you assume


Code palindrome in c using queue and stuck?

/** C Program to Check String is Palindrome using Stack.*/#include #include void push(char);char pop();char stack[100];int top = -1;void main(){char str[100];int i, count = 0, len;printf("Enter string to check it is palindrome or not : ");scanf("%s", str);len = strlen(str);for (i = 0; i < len; i++){push(str[i]);}for (i = 0; i < len; i++){if (str[i] == pop())count++;}if (count == len)printf("%s is a Palindrome string\n", str);elseprintf("%s is not a palindrome string\n", str);}/* Function to push character into stack */void push(char c){stack[++top] = c;}/* Function to pop the top character from stack */char pop(){return(stack[top--]);}


C program for checking a palidrome?

#include&lt;stdio.h&gt; main() { char a[20],b[20]; printf("enter a string"); scanf("%s",&amp;a); strcpy(b,a);//copies string a to b strrev(b);//reverses string b if(strcmp(a,b)==0)//compares if the original and reverse strings are same printf("\n%s is a palindrome",a); else printf("\n%s is not a palindrome",a); return 0; }


Write a PHP program to check whether the number is palindrome or not?

This program only suits PHP. If you want a proper one try C program for it available on web &lt;body&gt; &lt;?php if(isset($_POST['submit'])) { $text = $_POST['text']; $string = mysql_real_escape_string($text); $invert = strrev($string); if($string == $invert) { echo "&lt;br&gt;Given number is a palindrome!!"; } else { echo "&lt;br&gt;Given number is not a palindrome!!"; } } ?&gt; &lt;form method="post"&gt; &lt;input type="text" name="text" id="text" /&gt; &lt;input type="submit" name="submit" value="Submit" id="submit" onclick="&lt;?php $_SERVER['PHP_SELF']; ?&gt;" /&gt; &lt;/form&gt; &lt;/body&gt;


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"