Palindrome
Number:-
A Palindrome number is a number that remains
the same when we reverse the order of digits
For Example:-
121,232,12321 etc.
//Program
to display Palindrome Numbers from 100 to 200
#include<stdio.h>
#include<conio.h>
void
main()
{
//Declaration of variables
int a,n,r=0,i;
clrscr();
printf("\nList of Palindrome Number
from 100 to 200\n\n");
//start of for loop from i = 1 to
200
//incremented
each time by 1
for(i=100;i<=200;i++)
{
n = i; //value of i is stored
in n
//loop for
reversing the number
while(n > 0)
{
a = n % 10;
r = r * 10 + a;
n = n / 10;
}
//condition to check whether reverse
of
//the
number is equal to original or not
if (r == i)
{
printf("%d\t",i);
}
r = 0;
//set r = 0 as we have to check next number
}
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.