Decimal To Hexadecimal In Java

//DECIMAL TO HEXADECIMAL
class Dec2Hex{
    public void convert(int d){
        char c=' ';
        String s="";
        int r;
        while(d!=0){
            r=d%16;
            d=d/16;
            if(r<10)
            c=r>10?(char)(r+55):(char)(r+48);
            s=c+s;
        }
        System.out.println(s);
    }}
   
    

Comments

Popular posts from this blog

Sort Boundary Elements Of A Matrix

Lucky Number In Java ISC

Program to fill a square matrix of size ‘n*n” in a circular fashion (clockwise) with natural numbers from 1 to n*n, taking ‘n’ as input.