I wrote a program that converts decimal numbers (date of birth) to binary. Converting the day and month works smoothly, but when it comes to converting the year a problem occurs, for example 2001 is converted to 2521075409 instead of 11111010001. Could you tell me where the problem is?
{
int i;
long long temp, bin;
i = 1;
bin = 0;
printf("Number %d in binary: \n", year);
while (year > 0) {
temp = year % 2;
year /= 2;
bin += temp * i;
i *= 10;
}
printf("%lld\n\n",bin);
}