#include<iostream> #include<string.h> #include<iomanip> using namespace std; int HexaToDec(char *ch) { int i,base=1,temp,dec=0; i=strlen(ch)-1; while(i>=0) { if(ch[i]>='A'&&ch[i]<='F') temp=int(ch[i])-55; else temp=int(ch[i])-48; dec+=temp*base; base*=16; i--; } return (dec); } int main() { char ch[3]="1A"; cout<<"Enter a Hexadecimal number:-"; char hexa[100]; cin>>hexa; cout<<endl<<HexaToDec(hexa); return 0; }
Sunday, August 25, 2019
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment