int main()
{ decimal_to_anybase(10, 2);
decimal_to_anybase(255, 16);
getch(); }
decimal_to_anybase(int n, int base)
{ int i, m, digits[1000], flag; i=0;
printf("\n\n[%d] converted to base [%d] : ", n, base);
while(n)
{
m=n%base;
digits[i]="0123456789abcdefghijklmnopqrstuvwxyz"[m]
; n=n/base;
i++;
}
//Eliminate any leading zeroes for(i--;i>=0;i--)
{ if(!flag && digits[i]!='0')flag=1;
if(flag)printf("%c",digits[i]); } }
In the above code what is this statement doing?
digits[i]="0123456789abcdefghijklmnopqrstuvwxyz"[m]
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.