answersLogoWhite

0


Best Answer

Program

# include<stdio.h> void main() { long n,rev,t; int r; clrscr(); printf("Enter number : "); scanf("%ld",&n); t=n; rev=0; while(t>0) { r=t%10; rev=(rev*10)+r; t=t/10; } if(n==rev) printf("Number is palindrom"); else printf("Number is not palindrom"); getch(); }

algorithm

step 1 : input n

step 2 : s = 0, a=n

step 3 : while(n>0)

begin

rem=n%10

s=s*10+rem

n=n/10

end

step 4 : if(s==a)

print 'it is a palindrome'

else

print 'it is not a palindrome'

step 5 : stop

User Avatar

Wiki User

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

Wiki User

12y ago

// lets take testString="SAS"

boolean isPalindrome(String testString){

int length=testString.length();

for(int i=0;i<length/2;i++)

if(testString[i]!=testString[length-i+1])

return false;

//else it's palindrome

return true;

}

hope may be helpful

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write an algorithm and draw corresponding flow chart to check whether a given string is a palindrome or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Using Python write an algorithm that takes a string as input and determines whether or not it is a palindrome?

def isPalindrome(s): return s == s[::-1] then just call the function with a string like isPalindrome('poop')


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


Write a pseudo logic to check whether a string is palindrome or not?

Prepare the string for processing: Remove all punctuation from the string (e.g., commas, hyphens, whitespace, etc). Convert to the same case (e.g., lower-case). Instantiate two pointers, one pointing at the first character, the other pointing at the last character. Process: If the two pointers are pointing at the same position or have crossed each other, the string is a palindrome. Otherwise, compare the characters being pointed at. If they are not equal, the string is not a palindrome. Otherwise, move both pointers one position towards the middle of the string and repeat the process.


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


How can a stack determine if a string is a palindrome?

foreach char in string push on to stack create new string foreach char in string pop off and add to end of new string if new string equals old string palindrome else not palindrome //when you pop off the stack, the characters come off in reverse order, thus you have reversed the original string

Related questions

Using Python write an algorithm that takes a string as input and determines whether or not it is a palindrome?

def isPalindrome(s): return s == s[::-1] then just call the function with a string like isPalindrome('poop')


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

You can do this: &lt;?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not 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 (); }


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


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.


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


What are the explanation steps for palindrome program?

If you want to check whether a string is a palindrome, you can reverse the string (for example, the Java class StringBuffer has a reverse() method), and then compare whether the two strings - the original string and the reverted string - are equal. Alternately, you could write a loop that checks whether the first character of the string is equal to the last one, the second is equal to the second-last one, etc.; that is, you have a counter variable (in a "for" loop) that goes from zero to length - 1 (call it "i"), and compare character #i with character #(length-i-1) inside the loop.


What are examples of a palindrome program forward and backwards?

To check if a string is a palindrome, point to each end of the string and work inwards towards the middle. If the characters pointed at differ, the string is not a palindrome. When the pointers meet or cross each other, the string is a palindrome. Note that the string cannot contain whitespace or punctuation and comparisons must not be case-sensitive.


What is a string palindrome?

A string palindrome is some words that put together form a sentence. An example is "A man, a plan, a canal - Panama".


What is string palindrome?

A string palindrome is some words that put together form a sentence. An example is "A man, a plan, a canal - Panama".