Quantcast
Viewing all articles
Browse latest Browse all 39796

Help regarding the following code?

"Input The first line contains integer t, the number of test cases. Integers K are given in the next t lines. Output For each K, output the smallest palindrome larger than K."

#include<stdio.h>
#include<conio.h>
#include<math.h>

int main()
{
    int reverse=0,i,flag=0,k,t,m;
    scanf("%d",&t);
    while(t--)
 {
             scanf("%d",&k);

              m=k;
 while(flag!=1)
 {

               i=++m;

   while( i != 0 )
   {
      reverse = reverse * 10;
      reverse = reverse + i%10;
      i = i/10;
   }

   if (m == reverse )
     { 
         printf("%d",reverse);
         flag=1;  }
         }  
}
      getch();  
     return 0;
}

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>