int main() { char hx[256]; int decVal = 42; sprintf(hx,"%x",decVal); printf("Hex value of Decimal value %d is %s\n",decVal,hx); }