This deals only with the char append for the day number.
Replace your logic for this completely.
1) Use int n=day number % 10, to assign the right most digit of the day number, to n.
2) Use a small char arrray like this:
Code:
char append[4][4]={
{"th"},
{"st"},
{"nd"},
{"rd"},
{"th"}
};
Now the logic becomes simple:
Code:
#include <stdio.h>
int main(void) {
int i,n;
char append[5][4] = {
{"th"},
{"st"},
{"nd"},
{"rd"},
{"th"},
};
/* i represents the day number, here */
for(i=1;i<110;i++) {
n = i % 10; //get the value of the dates right most digit, assigned to n
if(i > 10 && i < 14)
n=0;
else if(n>4)
n=4;
printf("%4d%-3s ",i,append[n]);
}
printf("\n\n");
return 0;
}