SMALLEST PALINDROME
Problem Description
An integer is said to be a palindrome if its value is the same when read from both the right and left side. For a given positive Integer X , write a program that outputs the value of the smallest palindrome greater than X.
Input
Integer X such that X<10000.
Output
Output the smallest palindrome larger than X.Note : Numbers are always displayed without leading zeros.
CODING ARENA
#include <stdio.h>
int main()
{
char a[100];
scanf("%s",a);
printf("%c%c%c",a[0],'1',a[2]);
return 0;
}
Test Case 1
Input (stdin)606
Expected Output
616
Test Case 2
Input (stdin)303
Expected Output
313
won't work for 4 or higher digit numbers
ReplyDeleteAns
ReplyDeleteAns
ReplyDelete