write program for palindrome
Answers were Sorted based on User's Feedback
Answer / apoorv
#include<stdio.h>
#include<conio.h>
int main()
{
long int n,s=0,m,r;
printf("enter any no");
scanf("%ld",&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 | 1 No |
Answer / jamai partha
#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(s==n)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / ashok
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int i,j,f=0;
char a[10];
clrscr (); // only works on windows
gets(a);
for (i=0;a[i]!='\0';i++)
{
}
i--;
for (j=0;a[j]!='\0';j++,i--)
{
if (a[i]!=a[j])
{
printf("string is not palindrome");
return(0);
}
}
printf("string is palindrome");
return(0);
}
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / bhavesh vala
#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==n)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / m.sathish krishna
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,s=0,m;
clrscr();
printf("enter n");
scanf("%d",n);
m=n;
while(n>0)
(
r=n%10;
s=s*(10+r);
n=n/10;
}
if(m=n)
{
printf("it is palindrom");
}
else
{
printf("not a polindrom");
}
getch();
}
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / bala murali
#include<stdio.h>
#include<conio.h>
main()
{
char s1,s2;
printf("enter a string:");
gets(s1);
strcpy(s2,s1);
strrev(s2);
if(strcmp(s1,s2))
printf("palindrome:");
else
printf("not a palindrome:");
getch();
}
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / prakash
#include<stdio.h>
#include<conio.h>
main()
{
char s1[10],s2[10];
int m,i,j;
scanf("%s",s1);
strcpy(s2,s1);
m=strlen(s1);
for(i=0,j=m-1;i<=m-1,j<=0;i++,j--)
{
if(s1[i]!=s2[j])
printf("STRING IS NOT PALINDROME ");
}
printf("STRING IS a PALINDROME ");
getch();
}
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / krishna reddy
#include<stdio.h>
#include<conio.h>
void main()
{
int n,m,s,reverse=0;
clrscr();
printf("enter any no");
scanf("%d",&n);
m=n;
while(n!=0)
{
s=n%10;
reverse=reverse*10+s;
n=n/10;
}
if(m==reverse)
printf("the no is palindrome");
else
printf("no is not palindrome");
getch();
}
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / gunajit bhuyan (ulubar, guwaha
void main()
{
int n,num,digit,sum,rev;
printf("input a number to check for palindrom\n");
scanf("%d",&n);
n=num;
do
{
digit=num%10;
sum+=digit;
rev=rev*10+digit;
num/=10;
while (num!=0);
printf("sum of the digits of the number is =%d",sum);
printf("Reverse of the number is =%d",rev);
if(n==rev)
printf("this number is palindrom");
else
printf("this number is not palindrome");
getch();
}
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / md. irshad alam
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
clrscr();
int palind(char []);
int r;
char name[5];
cout<<"Enter a String...";
gets(name);
r=pal(name);
if(r==0)
{
cout<<"\n"<<"PALINDROME...";
}
else
{
cout<<"\n"<<"NOT A PALINDROME...";
}
getch();
}
int palind(char name[])
{
char *p,*t;
p=name;
t=name+strlen(name)-1;
while(*p)
{
if(*p != *t)
{
return(1);
}
p++;
t--;
}
return(0);
}
Is This Answer Correct ? | 0 Yes | 2 No |
What is the most powerful coding language?
What is meant by const_cast?
When should we use multiple inheritance?
How does c++ structure differ from c++ class?
What is c++ namespace?
Write a function which takes a character array as input and reverses it in place.
2 Answers Lehman Brothers, Vision Infotech,
Can we declare a base-class destructor as virtual?
If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
Mention the ways in which parameterized can be invoked.
Why c++ does not have finally?
Explain public, protected, private in c++?
What is difference between array and vector in c++?