link mingle home | logged in as: guest | login/register| submit link


IndiaDiscuss.com : Social Bookmarkings and News Networking Site for India
interview_questions
Bookmarks
Convert Decimal to Hexadecimal
-11
Votes

How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

saved under Amazon Interview Questions by interview_questions

 
char hex[20] = {'\0'}; int i = 0; while(num) { int x = num % 16; if(x>=0 && x<=9) { hex[i++] = '0' + x; } else { hex[i++] = 'A' + (x % 10); } } hex[i] = '\0'; strrev(hex);
comment by sachidanand on 2009-09-29 10:08:49
temp=""; while(n>0){ temp=array[n&15] + temp; n = n>>4; } where array is a sequence of characters from 0 to F.
comment by aravinds03 on 2010-09-25 16:11:24
 



Enter the string above
 
IndiaDiscuss | Published News | Hot
Indian Social News and Links Network
IndiaDiscuss | Published News
Indian Social News and Links Network