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 |
What are maps in c++?
How to create a reference variable in C++
What is a wchar_t in c++?
what is pre-processor in C++?
What are raw sockets, where they are efficient?
Can create new c++ operators?
What is std namespace in c++?
Do the parentheses after the type name make a difference with new?
What is static function? Explain with an example
What is the best free c++ compiler for windows?
How do I write a c++ program?
Explain method of creating object in C++ ?