Saturday 25 November 2017

C Program to print the next palindrome

#include <stdio.h>
#include <conio.h>
void main()
{
int n,i,k,r,s;
clrscr();
scanf("%d",&n);
for(i=n+1;;i++)
{
s=0;
k=i;
while(k>0)
{
r=k%10;
s=s*10+r;
k=k/10;
}
if(s == i)
{
printf("%d",i);
break;
}
}
getch();
}

No comments:

Post a Comment