Why? Where do these 1845,1846,821 come from?
%5c in scanf
reads exactly 5 characters
from the input and stores them as characters in a char array without adding a null terminator. But the code you provided currently is sing %5c with an int variable (int w) may causes scanf to interpret the w variable’s memory incorrectly. So it causes unpredictable results.
If you want to use %5c properly, you can declare w as a char array of sufficient size instead of int variable.
int y = 0;
char w[6] = {0};
scanf("%d %5c", &y, w);
printf("%d, %s\n", y, w);