write program for palindrome
Answers were Sorted based on User's Feedback
Answer / baskaran
import java.io.*;
class Polindrome1{
public static void main(String args[])
throws IOException{
String s,p;
BufferedReader obj1=new BufferedReader(new
InputStreamReader(System.in));
s=obj1.readLine();
System.out.println("Input Value:"+s);
p=new StringBuffer(s).reverse().toString();
if(s.equals(p)){
System.out.println("This Input Is
Polindrome:"+s);}
else
System.out.println("The Input Value Is Not
Polindrome");
}
}
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / nithya
#include<stdio.h>
#include<string.h>
main()
{
char str1[35];
char str2[35];
clrscr();
printf("Enter the string of words to check for
Palindrome or Not");
scanf("%s",&str1);
strcpy(str2,str1);
strrev(str2);
if(strcmp(str1,str2)==0)
printf("The entered string of words %s are
palindrome",str1);
else
printf("The entered string of words %s are not
palindrome",str1);
getch();
}
Is This Answer Correct ? | 3 Yes | 2 No |
Answer / anonymous
#include<stdio.h>
#include<stdlib.h>
main()
{
int i,j,len=0;
char name[25];
printf("Enter the string");
scanf("%s",&name);
while(name[len]!='\0')
len++;
printf("\n%d",len);
for(i=0,j=len-1;i<len/2;i++,j--)
{
if(name[i]!=name[j])
{
printf("The string is not a palindrome");
exit(0);
}
}
else
{
printf("The string is a palindrome");
}
}
}
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / muhammad umair arif
#include <iostream>
using namespace std;
void main()
{
int a,b,c,d,e,f;
cout<<"Enter three digit "<<endl;
cin>>a;
b=a/100;
c=a%100;
d=c/10;
e=c%10;
f=e;
if(f==b)
{
if(d==d)
{
if (b==f)
{
cout<<"It is Palindrome "<<endl;
}
}
}
else
cout<<"It isnot Palindrome "<<endl;
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sanam baig
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,m,r;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(s == m) // This is important step
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / akash
#include<stdio.h>
#include<conio.h>
void main()
{
int n,rev=0,r;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
rev=rev*10+r;
n=n/10;
}
printf("reverse of the number is %d",rev);
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sowmya
#include,studio.h>
#include<conio.h>
void main()
{
int num,mod,rev=0;
clrscr();
printf("Enter any no:");
scanf("%d",&n);
while(n>=0)
{
mod=n%10;
rev=rev*10+mod;
n=n/10;
}
if(rev=n)
{
printf("palindrome");
}
else
{
printf("not palindrome");
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / arungmail.com
Ans 9# is working with out make that as long int.....
n=n/10 for iterating n value,.
Buts var alone holds the required output...
So the comp must be made between s & m
as like if(s==m)
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sanmathi
#include<stdio.h>
#include<conio.h>
main()
{
char str1[20],rev[20];
int i,j=0;
clrscr();
printf("\n enter a word");
gets(str 1);
for(i=strlen(str 1)-1;i>=0;i--)
{
rev[j]=str[i];
j++;
}
rev[j]='\0';
printf("\n the given string is.........%s",str 1);
printf("\n the reversed string is .....%s",rev);
if(strcmp(str1,rev)==0)
{
printf("\n the given string is a palindrome");
}
else
{
printf("\n the given string is not a palindrome");
}
getch();
}
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / purnachandra sahoo
/*Program to check whether a number is palindrom or not*/
#include<iostream.h>
#include<conio.h>
int pall(int);
void main()
{
int n,res;
clrscr();
cout<<"Enter the number :";
cin>>n;
res=pall(n);
cout<<" which is:"<<res;
getch();
}
int pall(int x)
{
int p,a,sum=0;
p=x;
while(x!=0)
{
a=x%10;
sum=sum*10+a;
x=x/10;
}
if(sum==p)
{
cout<<"\nThe enterd number is palindrom" ;
return(sum);
}
else
{
cout<<"\nThe entered number is not palindrom" ;
return 0;
}
}
Is This Answer Correct ? | 1 Yes | 0 No |
When do we use copy constructors?
What is the Difference between "printf" and "sprintf"?
7 Answers iSoft, PentaWare, TCS,
How do you invoke a base member function from a derived class in which you’ve overridden that function?
How to access a variable of the structure?
What will i and j equal after the code below is executed? Explain your answer.
Is rust better than c++?
What is a c++ class?
if int1 has the value 12, int has the value 18, and int3 has the value 21, what is the result: int1 < int2 && int2 < int 3
what does the following statement mean? int (*a)[4]
What is difference between malloc()/free() and new/delete?
What is a set in c++?
Comment on assignment operator in c++.