#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int i, j, b = 1, l;
unsigned long long int s = 0;
char an[100];
cout << "Enter Hexadecimal Number : ";
cin >> an;
cout << endl;
l = strlen(an);
for(i=l-1;i>=0;i--)
{
if(an[i] >= '0' && an[i] <= '9')
{
s = s + (an[i] - 48) * b;
b = b * 16;
}
else if(an[i] >= 'A' && an[i] <= 'F')
{
s = s + (an[i] - 55) * b;
b = b * 16;
}
}
cout << "Decimal Number :: " << s << endl;
return 0;
}
#include<string.h>
using namespace std;
int main()
{
int i, j, b = 1, l;
unsigned long long int s = 0;
char an[100];
cout << "Enter Hexadecimal Number : ";
cin >> an;
cout << endl;
l = strlen(an);
for(i=l-1;i>=0;i--)
{
if(an[i] >= '0' && an[i] <= '9')
{
s = s + (an[i] - 48) * b;
b = b * 16;
}
else if(an[i] >= 'A' && an[i] <= 'F')
{
s = s + (an[i] - 55) * b;
b = b * 16;
}
}
cout << "Decimal Number :: " << s << endl;
return 0;
}
Comments
Post a Comment