write program for palindrome
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Which is the best c++ software?
what is static function
What is the history of c++?
What is a null object in c++?
How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?
If dog is a friend of boy and boy is a friend of house, is dog a friend of house?
Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
What are the total number of lines written by you in C/C++? What is the most complicated or valuable program written in C/C++?
Which sort is best for the set: 1 2 3 5 4 a) Quick Sort b) Bubble Sort c) Merge Sort
What is the topic of the C++ FAQ list?
Can a function take variable length arguments, if yes, how?
What is the difference between new/delete and malloc/free?