Page 1 of 1

## 1 Replies - 7858 Views - Last Post: 26 March 2008 - 11:01 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=47401&amp;s=63af793e0dd65d52a746722b3817de71&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 sumit_bhutaniin

Reputation: 0
• Posts: 1
• Joined: 26-March 08

Posted 26 March 2008 - 10:56 PM

#include <iostream.h>

main()
{
// Initialize the variables
unsigned long a,b,c,d,base10IP;

// Get the IP address from user
cout << "\nwith each section seperated by a space: ";
cin >> a >> b >> c >> d;

// Do calculations to covert IP to base 10
a *= 16777216;
b *= 65536;
c *= 256;
base10IP = a + b + c + d;

cout << "\nThe converted address is: " << base10IP << '\n';
}

this is the following code which i could manage to figure out, please help me to convert this from decimal to hexa also if possible please send me a C++ program to convert hexadecimal notation to decimal notation

Is This A Good Question/Topic? 0

### #2 no2pencil

• Professor Snuggly Pants

Reputation: 6611
• Posts: 30,823
• Joined: 10-May 07

Posted 26 March 2008 - 11:01 PM

...2nd result on Google searching "convert decimal to hex".
```int main() {
char outStr[256];
int inDec = 65535;
sprintf(outStr,"%x",inDec);
printf("%d in hex is %s\n",inDec,outStr);
}

```

Quote

also if possible please send me a C++ program

No one is going to give you a program. We will do our best to help you out, & answer questions, but we don't give out programs here, sorry.