Next Palindromic Number
C CODE:
#include<stdio.h>
#include <stdlib.h>
int main()
{
int n;
scanf("%d",&n);
palindrome(n);
}
int palindrome(int x)
{
int i,f=0,rev;
for(i=x+1;f==0;i++)
{
rev=reverse(i);
if(i==rev)
{
printf("%d",i);
f++;
}
}
}
int reverse(int i)
{
int r,revno=0;
while(i>0)
{
r=i%10;
revno=revno*10+r;
i=i/10;
}return revno;
}
Comments
Post a Comment