Thanks dpitz. Your suggestion was right on target,I missed to spot the obvious, I have changed the statement to in my code and also found that I was printing with the wrong index values.
Instead of printing with index value i, I was printing with index value ndigit in my output loop. Here's my modified code that gives me the right answer.
char digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
printf("Enter the number to be converted");
printf("Enter the base between 2 and 36 to which the number is to be converted");
newrep[ndigit] = digits[r];
/* newrep[ndigit]=(char)ascii; */
printf("Base %d representation of %d is\n",newbase,n);
i = ndigit;
printf("\ni = %d\n", i);
Originally Posted by dpitz