write program for palindrome

Answers were Sorted based on User's Feedback



write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

Post New Answer

More C++ General Interview Questions

What do you mean by pure virtual functions in C++? Give an example?

1 Answers  


How do you invoke a base member function from a derived class in which you have not overridden that function?

0 Answers  


What is the average salary of a c++ programmer?

0 Answers  


What is istream c++?

0 Answers  


Should I learn c++ c?

0 Answers  






Which software is best for c++ programming?

0 Answers  


What is the difference between an external iterator and an internal iterator? Describe an advantage of the external iterator.

0 Answers  


What do you understand by zombie objects in c++?

0 Answers  


What do you mean by early binding?

0 Answers  


What is the basic difference between C and C++?

0 Answers   NIIT,


What is namespace std; and what is consists of?

0 Answers  


Is c++ a software?

0 Answers  


Categories