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

Explain the term memory alignment?

0 Answers  


Write a short code using c++ to print out all odd number from 1 to 100 using a for loop

0 Answers  


Describe delete operator?

0 Answers  


When copy constructor can be used?

4 Answers   Symphony,


What are the steps in the development cycle?

0 Answers  






What kind of jobs can I get with c++?

0 Answers  


Implement strncpy

3 Answers  


What is pointer to member?

0 Answers  


What is the exit function in c++?

0 Answers  


Who calls main function?

0 Answers  


what is difference between internet and Internet?

12 Answers   College School Exams Tests, Microsoft, MIT, TCS,


What can I safely assume about the initial values of variables which are not explicitly initialized?

0 Answers  


Categories