if (i>=0 && i<=9) c=i+'0';
Or just generate random numbers between '0' and '9'.