A program that read any hexadecimal number & display equivalent decimal number in Cpp.

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<string.h>

void main()
{
    char st[100];
    long i,n,l;
    clrscr();
    cout<<"Enter any hexadecimal number : ";
    cin>>st;
    n=0;
    l=strlen(st);
    for(i=0;i<l;i++)
    if(st[i]>='0' && st[i]<='9')
    n=n*16+st[i]-48;
    else if(st[i]>='A' && st[i]<='F')
    n=n*16+st[i]-55;
    else if(st[i]>='a' && st[i]<='f')
    n=n*16+st[i]-87;
   
    cout<<"Equivalent decimal number is : "<<n;
    getch();
}


////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........