Monday, May 7, 2018

Write a C program to find the Palindrome numbers in a given range.



Palindrome numbers:   A palindromic number or numeral palindrome is anumber that remains the same when its digits are reversed. Like 16461, for example, it is "symmetrical". The term palindromic is derived from palindrome, which refers to a word (such as rotor or race car) whose spelling is unchanged when its letters are reversed.



#include<stdio.h>
int main()
{
int n1,n2, n3,n,s,r;
printf("Enter The Range : ");
scanf("%d%d",&n1,&n2);
printf("Palindrome numbers are : ");
for(n=n1;n<=n2;n++)
{
n3 = n;
for(s=0;n3>0;n3=n3/10)
{
r=n3%10;
s=s*10+r; //Reverse number
}
if(s==n)  
           printf("%d ",s);             //Palindrome 

}
        return 0;
}



OUTPUT:

Enter The Range : 2      200

Palindrome numbers are : 2 3 4 5 6 7 8 9 11 22 33 44 55 66 77 88
99 101 111 121 131 141 151 161 171 181 191

0 comments: