write program for palindrome
Answers were Sorted based on User's Feedback
Answer / chintan
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char *a,*b,s1[10],s2[10];
cout<<"\n ENTER THE STRING : ";
cin>>s1;
strcpy(s2,s1);
a=s1;
b=s2;
strrev(s2);
cout<<s2;
if(strcmp(a,b))
cout<<" \n STRING IS NOT PALINDROME ";
else
cout<<" \n STRING IS PALINDROME ";
getch();
}
Is This Answer Correct ? | 35 Yes | 31 No |
Answer / devunegi.negi
write program for palindrome in jdk........
import java.i.*;
class palindroame
{
public static void main(String args[])throws IEXception
int n,s,rev,m;
n=s
BufferedReader br =new BufferedReader(new InputStreamReader
(System.in));
System.out.println("Enter the Digit=");
s=Integer.parseInt(br.readLine());
While(s!=0)
{
m=s%10;
rev=(10*rev)+m;
s=s/10;
}
if(rev==n)
System.out.println("This number is Palindrome");
else
System.out.println("This number is Not palindrome");
}
Is This Answer Correct ? | 13 Yes | 9 No |
Answer / mojib khan
#include<stdio.h>
void main()
{
int i=0,l,flag=0;
char str[30];
clrscr();
printf("Enter the string\n");
gets(str);
l=strlen(str)-1;
while(i<=l)
{
if(str[i]==str[l])
flag=1;
else
{
flag=0;
break;
}
i++;
l--;
}
if(flag==1)
printf("String is palindrom");
else
printf("\n String is not palindrom");
getch();
}
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / gaurav joshi
#include <stdio.h>
int main()
{
int number,temp,remainder,sum=0;
printf("nnEnter no: ");
scanf("%d",&number);
temp = number; //Value of temp stores unmodified n value
while(number>0)
{
remainder=number%10;
number/=10;
sum=sum*10 + remainder; //Builds value of reversed number
}
if (sum==temp)
printf ("nThe Number Is A Palindrome ");
else
printf ("nThe Number Is Not A Palindrome ");
getch ();
return 0;
}
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / gaurav joshi garur (bageshwar)
#include<stdio.h> main()
{
int n, reverse = 0, temp; printf("Enter a number to check if it is a
palindrome or not\n");
scanf("%d",&n); temp = n; while( temp != 0 )
{
reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
} if ( n == reverse )
printf("%d is a palindrome number.\n", n);
else
printf("%d is not a palindrome number.\n",
n); return 0;
}
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / deepa garia
#include<stdio.h>
#include<conio.h>
int main()
{
int r,n,k=0,l;
printf("\nENTER THE NUMBER ");
scanf("%d",&n);
l=n;
while(n>0)
{
r=n%10;
n=n/10;
k=k*10+r;
printf("%d",r);
}
if(k==l)
printf("\npalindrome");
else
printf("\n not palindrome");
getch();
return 0;
}
Is This Answer Correct ? | 16 Yes | 13 No |
Answer / niruj
/* without using string.h library */
#include<stdio.h>
#include<conio.h>
void main()
{
char *p;
char a[]="malyalam";
char rev[10];
int i;
int len=sizeof(a);
p=a;
do{
p++;
}while(*p!=NULL);
*p='\0';
i=0;
do{
p--;
rev[i]=*p;
i++;
}while(p!=a);
for(i=0;i<=len-2;i++)
{
if(a[i]==rev[i])
{
if(i==len-2)
{
printf("String is Pallindrom");
}
}
else{
printf("String is not pallindrom");
break;
}
}
getch();
}
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / ram thilak.p
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[20];
int c;
printf("\n\n\t Enter A String:");
scanf("%s",a);
c=strcmpi(strrev(a),a);
if(c==0)
{printf("\n %s is a Palindrome",a);}
else
{printf("\n %s is not a Palindrome",a);)
getch();
}
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / varun tiwari
#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)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / syfith
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,k,i,t,rev;
cout<<"enter your number = ";
cin>>n;
k=n;
while(t>0)
{
i=n%10;
rev=rev*10+i;
t=n/10;
n=n/10;
}
if(rev==k)
cout<<"it is a palindrome";
else
cout<<"it is not a palindrome";
getch();
}
Is This Answer Correct ? | 2 Yes | 0 No |
Is c++ double?
What is long in c++?
What is compilation?
How would you use the functions memcpy(), memset(), memmove()?
In int main(int argc, char *argv[]) what is argv[0] a) The first argument passed into the program b) The program name c) You can't define main like that
what is the diff b/n c and c++ a. dynamic scoping b. nested switching c. declaration of variables in any code block d. separation of compilation and linking
Explain calling an object's member function(declared virtual)from its constructor?
Why cstdlib is used in c++?
Can you write a function similar to printf()?
What is an ABC: an "Abstract Base Class"?
What is the purpose of template?
Are vectors faster than arrays?