The conversion i wrote of hexadecimal to decimal number is not working. I am not sure what part is wrong. Do i have to do -7 or something else.
int hex_to_dec(char hexnumber[])
{
int decimal = 0; //integer for the final decimal number
    int bit; //integer representing numbers between 0-9 and letter a-f in hex number
    //a char array containing the input hex number
    int i=0,j=0;
    //the integer i takes the length of the input array
    i =strlen(hexnumber);
    //while there is a next bit in the array
    while(i!=0)
    {
    bit = hexnumber[j];
    //if the bit is a digit do the following
    if(('0' <= bit && bit <= '9'))
    {
    decimal = decimal * 16;
    decimal = decimal + (bit - '0');
    }
    //if the bit is a letter do the following
    if(('a' <= bit && bit <= 'z'))
    {
    decimal = decimal * 16;
    decimal = decimal + (bit - '7');
    }
    i--;
    j++;
    }
 if(('a' <= bit && bit <= 'z'))
    {
    decimal = decimal * 16;
    decimal = decimal + (bit - '7');
    }
   cout<<decimal;
    return decimal;
}
The above is my code for the same.
 
     
     
    