write program for palindrome

Answers were Sorted based on User's Feedback



write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

write program for palindrome..

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

Post New Answer

More C++ General Interview Questions

What are the various oops concepts in c++?

0 Answers  


What problems might the following macro bring to the application?

0 Answers  


What are features of c++?

0 Answers  


What is volatile and pragma? When they are used?

1 Answers  


What are shallow and deep copies?

0 Answers  






Why is main function important?

0 Answers  


Define stacks. Provide an example where they are useful.

0 Answers  


Is c++ free?

0 Answers  


Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.

0 Answers  


What and all can a compiler provides by default?

3 Answers   Accenture, HP,


What do you mean by early binding?

0 Answers  


Is c++ a good first language to learn?

0 Answers  


Categories