Advice: Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes.
#include<stdio.h>
int givenValue;
int sizeCounter(int givenValue);
int main(void) {
int size, givenValue, th, numofpalindrome = 0;
int i, j, k, notpalindrome;
scanf("%d", & th);
givenValue = 1;
while (numofpalindrome < th) {
j = givenValue;
size = sizeCounter(givenValue);
int array[size];
i = size - 1;
while (givenValue != 0) {
array[i] = givenValue % 10;
givenValue = givenValue / 10;
i--;
}
notpalindrome = 0;
for (k = 0; k < (size / 2); k++) {
if (array[k] != array[size - k - 1]) {
notpalindrome = 1;
break;
}
}
if (notpalindrome == 0) {
numofpalindrome++;
}
givenValue = j;
givenValue++;
}
printf("%d", givenValue - 1);
return 0;
}
int sizeCounter(int givenValue) {
int x = 0, y;
y = givenValue;
while (givenValue != 0) {
givenValue = givenValue / 10;
x++;
}
givenValue = y;
return x;
}
Indentation style - Wikipedia[
^]
Best C++ Formatter and Beautifier[
^]
Online C/C++ Formatter, Indenter and Beautifier – Techie Delight[
^]
Professional programmer's editors have this feature and others ones such as parenthesis matching and syntax highlighting.
Notepad++ Home[
^]
ultraedit[
^]
Enabling Open Innovation & Collaboration | The Eclipse Foundation[
^]
Advice: Learn to separate concerns. Making a function for
nthpalindrome(int)
will help to make clearer each variables usage.