public class Test {
public static void main(String[] args) {
System.out.println("Dec number 8 to Hex value is: " + convertDecimalToBinary(8));
System.out.println("Dec number 298 to Hex value is: " + convertDecimalToBinary(298));
System.out.println("Dec number 9123 to Hex value is: " + convertDecimalToBinary(9123));
}
public static String convertDecimalToBinary ( int value){
return Integer.toHexString(value);
}
}
-----output
Dec number 8 to Hex value is: 8
Dec number 298 to Hex value is: 12a
Dec number 9123 to Hex value is: 23a3
#include
void main()
{
int i;
printf("Please input a number to i:");
scanf("%d",&i);
printf("i=%x",i);
}