write program for palindrome

Answers were Sorted based on User's Feedback



write program for palindrome..

Answer / sat

#include<stdio.h>
#include<string.h>
void main()
{
char a[40],b[40];
printf("\n Enter String:= ");
gets(a);
strcpy(b,a);
strrev(b);
if(strcmp(b,a)==0)
printf("\n Entered string \"%s\" ispalindrome",b);
else
printf("\n Entered string \"%s\" is not palindrome",a);
}

Is This Answer Correct ?    0 Yes 0 No

write program for palindrome..

Answer / saurav sadangi

#include<stdio.h>

int main(){
int n,s=0,r,m;
printf("Enter m:- ");
scanf("%d",&m);

n=m;

while(m>0){
r=m%10;
s=(s*10)+r;
m/=10;
}
printf("The reverse no is %d\n",s);

if (s==n)
printf("%d is pallendrom.\n",n);
else
printf("%d is not pallendrom.\n",n);

system("PAUSE");
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

write program for palindrome..

Answer / lakshmi narayana

#include<stdio.h>

main()
{
int n,s=0,m;

printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
int r=n%10;
s=s*10+r;
n=n/10;
}
if(s == m) // This is important step
printf("the no is palindrome\n");
else
printf("no is not palindrome\n");
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

write program for palindrome..

Answer / anonymous

#include<stdio.h>
#include<conio.h>
int main()
{
int n,s=0,m,r;
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(m==s)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
return 0;
}

Is This Answer Correct ?    0 Yes 0 No

write program for palindrome..

Answer / dharm

#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,m;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
s=s*10+r;
n=n/10;
}
if(m==s)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}

Is This Answer Correct ?    0 Yes 0 No

write program for palindrome..

Answer / amit

#include<iostream.h>
#include<conio.h>
main()
{
char c[8];
cout<<"enterd hte world of polindorom";
cin>>c;
int i=strlen(c);
i=i-1;
int flag=0;
for(int j=0;j<=1;j++)
{
if(c[j]==c[i])
{
flag=1;
}
else
{
int flag=0;
break;
}
}
i--;
if(flag==1)
{
cout<<"your option is polindorome";
}
else
{
cout<<"your option is not polindorome";
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

write program for palindrome..

Answer / darren chang

bool palind(string input)
{
int j=input.length()-1;
int i=0;
while(i<j)
{
if(input[i]!=input[j])
return false;
i++;
j--;
}
return true;
}

Is This Answer Correct ?    23 Yes 24 No

write program for palindrome..

Answer / deepanjan

#include<stdio.h>
void main()
{
char ch[100];
int i,j,l,flag;
l=0;
flag=0;
printf("\n Enter to check if palindrome or not \n");
gets(ch);
for(i=0;ch[i]!='\0';i++)
{
l++;
}
for(i=0,j=l-1;i<(l/2)-1,j>(l/2);i++,j--)
{
if(ch[i]==ch[j])
flag=0;
else
{
flag=1;
break;
}
}
if(flag==0)
printf("\n Entered characters are palindrome");
else
printf("\n Entered characters are not a palindrome");

}

Is This Answer Correct ?    14 Yes 15 No

write program for palindrome..

Answer / anirban

#include<stdio.h>
#include<string.h>
#define size 26

void main()
{
char strsrc[size];
char strtmp[size];

clrscr();
printf("\n Enter String:= "); gets(strsrc);

strcpy(strtmp,strsrc);
strrev(strtmp);

if(strcmp(strsrc,strtmp)==0)
printf("\n Entered string \"%s\" ispalindrome",strsrc);
else
printf("\n Entered string \"%s\" is not
palindrome",strsrc);
getch();
}

Is This Answer Correct ?    12 Yes 13 No

write program for palindrome..

Answer / kumaran

int a,n,s,x=0;
a=n;
while(n>0)
{
s=n%10;
x=x*10+s;
n=n/10;
}
if(a=n)
printf("palindrome");
else
printf("not palindrome");

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C++ General Interview Questions

what are prototypes

4 Answers   Infosys, TCS,


What is RTRT tool?can it be used for automation?can it work on packet PC?

3 Answers  


When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?

0 Answers  


Explain about profiling?

1 Answers  


What is recursion?

0 Answers  






How did c++ start?

0 Answers  


Write a C++ program that asks the user to choose a number between 1 and 1000. Then, your program should be able to guess the number by asking the user no more than 10 yes/no questions. Use a while loop in your program

1 Answers  


What is null pointer and void pointer and what is their use?

0 Answers  


Which is better c++ or java?

0 Answers  


Explain the difference between 'operator new' and the 'new' operator?

1 Answers   Lucent, TCS,


Why is main function important?

0 Answers  


Explain what data encapsulation is in c++?

0 Answers  


Categories