Printing hexadecimal value of a given integer using recursion can be accomplished as below:
printHex(unsigned int i)
{
if(i ==0) return;
printHex(i/16);
if((i%16) < 10) {
putchar('0' + i%16);
}
else {
putchar('A' + i%16 - 10);
}
}
printHex(unsigned int i)
{
if(i ==0) return;
printHex(i/16);
if((i%16) < 10) {
putchar('0' + i%16);
}
else {
putchar('A' + i%16 - 10);
}
}
Comments
Post a Comment
https://gengwg.blogspot.com/