how to write palindrome program?

Answers were Sorted based on User's Feedback



how to write palindrome program?..

Answer / a.prathyusha

#include<stdio.h>
void main()
{
int n,s=0,r,n1;
printf("enter any number:");
scanf("%d",&n);
n1=n;
while(n>0)
{
r=n%10;
s=(s*10)+r;
n=n/10;
}
if(s==n1)
printf("palindrom");
else
printf("not palindrom");
}

Is This Answer Correct ?    7 Yes 1 No

how to write palindrome program?..

Answer / arnab

#include<iostream.h>
#include<conio.h>
void main()
{ int num, num1, rem, rev=0;
cin>>num;
num1=num;
while(num!=0)
{
rem=num%10;
rev=rev*10+rem;
num=num/10;
}
if(num1==rev)
cout<<"yes the no. is pallindrome";
else
cout<<"no the no. is not pallindrome";
getch();
}

Is This Answer Correct ?    0 Yes 0 No

how to write palindrome program?..

Answer / shweta

when we do reverse any no then we find a new no and this
no is equal to our privous no,which is called palindrom no.
by program
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n,m,sum=0,l;
printf("enter any no");
scanf("%d",&n);
while(n>0)
{
m=n%10;
sum=sum*10+m;
n=n\10;
}
if(n==l)
{
printf("no is palindrom");
}
else
{
printf("no is not palindrom");
}
getch();
}

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More C Interview Questions

how to find sum of 5 digits in C?

4 Answers  


what is difference between procedural language and functional language ?

4 Answers   Wipro,


Can we include one C program into another C program if yes how?

7 Answers   Infosys,


What does 3 periods mean in texting?

0 Answers  


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

0 Answers  


how logic is used

0 Answers  


`write a program to display the recomended action depends on a color of trafic light using nested if statments

0 Answers  


Every time i run a c-code in editor, getting some runtime error and editor is disposing, even after reinstalling the software what may be the problem?

2 Answers  


Write a program to generate the first n terms in the series --- 9,11,20,31,...,82

1 Answers   Cognizant,


What is the explanation for the dangling pointer in c?

0 Answers  


write a program for odd numbers?

15 Answers  


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

0 Answers   Huawei,


Categories