answersLogoWhite

0


Best Answer

/*To check whether a string is palindrome*/

  1. include
  2. include
void 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 ();
}
User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

If you mean not using pointers, then:

int palindrome (const char s[])

{

size_t len, i, j;

len = strlen (s);

for (i=0, j=len-1, check=1; check==1 && i

if (s[i] != s[j]) check= 0;

}

return check;

}

but if it's using pointers, then: int palindrome (const char *s)

{

size_t len;

const char *p, *q;

len = strlen (s);

for (p=s, q=s+len-1, check=1; check==1 && p

if (*p != *q) check= 0;

}

return check;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

int palindrome(char * string)

{

int result = 0;

int count = 0;

char * a = string;

char * b = string+strlen(string);

while((*a++ strlen(string))

result = 1;

return result;

}

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

#include

#include

#include

void main()

{

clrscr();

int i,j=0;

char s[40]=" ";

int p = 1;

printf("/nEnter the string;");

gets(s);

for(i=strlen(s)-1;i>=0;i--,j++)

{

if (s[j] !=s[i])

{

p=0;

break;

}

}

if(p)

printf("Given string %s is palindrome",s);

else

printf("Given string %s is not palindrome",s);

getch();

}

strlen is one of the string functions

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

#include<stdio.h>

#include<ctype.h>

#include<string.h>

/* returns true of the given string represents a palindrome,

otherwise returns false */

bool is_palindrome (const char* str) {

size_t len;

char *left, *right;

if (!str) return false; /* null-strings are not palindromes */

len = strlen (str);

if (!len) return false; /* empty strings are not palindromes */

left = (char*) str;

right = (char*) str + len - 1;

while (left<right && *left==*right) {

++left;

--right;

}

return (*left==*right);

}

int main (void) {

char str[BUFSIZ], cpy[BUFSIZ];

size_t i, index;

printf("Enter a string: ");

gets(str);

/* strip punctuation and convert to lower case */

i=0;

for (index=0;index<BUFSIZ;++index) {

cpy[i]=tolower(str[index]);

if (cpy[i]>='a' && cpy[i]<='z')

++i;

}

cpy[i]='\0';

/* print result */

printf ("The string "%s" is ", str);

if (!is_palindrome (cpy))

printf ("not ");

printf ("a palindrome.\n");

}

Example usage:

Enter a string: Madam, I'm Adam

The string "Madam, I'm Adam" is a palindrome.

Enter a string: Madam, I'm not Adam

The string "Madam, I'm not Adam" is not a palindrome.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you check given string is palindrome or not with out using string functions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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


Bluej program-read a string and check if the given string is a palindrome?

import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i&lt;failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}


Wap in c plus plus to find out the string is palindrome or not in?

use the strrev() function on the given string and compare with original string.If both are equal they are palindromes else not.


How do you check whether a string is palindrome or not using vb Script?

Private Sub Command1_Click() a = Text1.Text b = StrReverse(a) If a = b Then Print "palindrome" Else Print "not palindrome" End If End Sub


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;

Related questions

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.


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


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

int Palindrome(char *userStringStart) { char *userStringEnd = userStringStart; do { *userStringEnd |= 32; } while(*++userStringEnd); do{ while(*userStringStart &lt; 97 *userStringStart &gt; 122) userStringStart++; while(*userStringEnd &lt; 97 *userStringEnd &gt; 122) userStringEnd--; if(*userStringStart != *userStringEnd) return 0; } while(userStringStart++ &lt;= userStringEnd--); return 1; }


Bluej program-read a string and check if the given string is a palindrome?

import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i&lt;failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}


Design an algorithm to check whether a given string is a palindrome or not?

#include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;string.h&gt; void input(char a[ ]) { int i; printf("\n enter string\n"); scanf("%s",a); } void output(char a[ ]) { printf("\n string is %s",a); } int palindrome(char a[ ]) { int n,i; n=count(a); n=n-1; i=0; for(;a[n]==a[i] &amp;&amp; n&gt;=i;i++,n--); if(n&gt;=i) return 0; else return 1; } void main( ) { char a[80],b[80],s; int n; printf("\n check palindrome"); input(a); n=palindrome(a); output(a); if(n==1) printf("\n palindrome"); else printf("\n not palindrome"); getch(); }


Design a algorithm to check whether a given string is palindrome or not?

#include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;string.h&gt; void input(char a[ ]) { int i; printf("\n enter string\n"); scanf("%s",a); } void output(char a[ ]) { printf("\n string is %s",a); } int palindrome(char a[ ]) { int n,i; n=count(a); n=n-1; i=0; for(;a[n]==a[i] &amp;&amp; n&gt;=i;i++,n--); if(n&gt;=i) return 0; else return 1; } void main( ) { char a[80],b[80],s; int n; printf("\n check palindrome"); input(a); n=palindrome(a); output(a); if(n==1) printf("\n palindrome"); else printf("\n not palindrome"); getch(); }


Write an algorithm to check whether a given string is palindrome or not?

#include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;string.h&gt; void input(char a[ ]) { int i; printf("\n enter string\n"); scanf("%s",a); } void output(char a[ ]) { printf("\n string is %s",a); } int palindrome(char a[ ]) { int n,i; n=count(a); n=n-1; i=0; for(;a[n]==a[i] &amp;&amp; n&gt;=i;i++,n--); if(n&gt;=i) return 0; else return 1; } void main( ) { char a[80],b[80],s; int n; printf("\n check palindrome"); input(a); n=palindrome(a); output(a); if(n==1) printf("\n palindrome"); else printf("\n not palindrome"); getch(); }


Wap in c plus plus to find out the string is palindrome or not in?

use the strrev() function on the given string and compare with original string.If both are equal they are palindromes else not.


WAP to find Palindrome in given sentence like - The new radar is placed on station - asked in persistent written test?

plz any1 give code on given exampleAs i know we can check String is it palindrome or not..take a look onCode_for_palindrome_checking_in_c_programmingorvoid main(){char strsrc[100];char strtmp[100];printf(" Enter String:= ");gets(strsrc);strcpy(strtmp,strsrc);strrev(strtmp);if(strcmp(strsrc,strtmp)==0)printf("\n Entered string " %s " is palindrome",strsrc);elseprintf("\n Entered string "%s" is not palindrome",strsrc);getch();}You cite 2 examples of what you are looking for so why are you asking the question? The palindrome is word "radar" so obviously the program needs to extract individual word from the string in order to test. That is a simple thing to do. I am not going to do it for you because if I do you do not learn what you need to know.....i did separated string by for (i=0 arr!=arr.lnegth i++){if(arr[i]==" ")} then each string checked for this code but that not right as persistence employee said..


How do you check whether a string is palindrome or not using vb Script?

Private Sub Command1_Click() a = Text1.Text b = StrReverse(a) If a = b Then Print "palindrome" Else Print "not palindrome" End If End Sub


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;


Program to check palindrome using recursion?

#include &lt;stdio.h&gt; #include &lt;conio.h&gt; void main() { int num,rev=0,m,r; clrscr(); printf("enter any number"); scanf("%d",&amp;num); m=num; while(num&gt;0) { r=num%10; rev=rev*10+r; num=num/10; } if(rev==m) printf("given number is palindrome"); else printf("given number is not palindrome"); getch(); } this is the answer.