Thursday, July 12, 2012
Write a program to convert hexadecimal string to decimal number.

The solution:-
#include <iostream>
using namespace std;

int main() {
char input[] = "64";
int val = 0;
char* ptr = input;

while ( *ptr != '' ) {
val = val * 16 + *ptr - '0';
ptr++;
}

cout << val << endl;
return 0;
}

Output:-
100

2 comments :

  1. Hey there! What a nice looking site you own! Did you organize this site on your own?

    ReplyDelete
  2. Can anyone explain how does this work ?

    ReplyDelete

Contact Form

Name

Email *

Message *

Back to Top