Hello! I am trying to solve the “Next Palindrome” in C and everything seems to be working on my compiler as well as ideone, but it is showing as incorrect on the system. I’m hoping someone can point out where I may be going wrong. Thank you!
#include <stdio.h>
int main () {
int total, temparray, remainder;
scanf("%d", &total);
int array[total], revarray[total];
for (int i = 0; i < total; i++) {
scanf("%d", &array[i]);
revarray[i] = 0;
}
for (int i = 0; i < total;){
array[i]++;
temparray = array[i];
while (temparray) {
remainder = temparray % 10;
revarray[i] = revarray[i] * 10 + remainder;
temparray /= 10;
}
if (array[i] == revarray[i]) {
printf("%d\n", revarray[i]);
i++;
} else {
revarray[i] = 0;
}
}
}