# help storing and calculating hex values

• 07-13-2003
anzas
help storing and calculating hex values
Code:

```#include <iostream.h> int main()    //*this program basicly takes 2 numbers and adds them together {                    //*10 times (every time showing the result) int a;      //*declaring var's int x; int z; cout<<"enter offset to calculate:";  //asks for the first number cin>>a;                              //stores first number in var "a" cout<<"enter diffrence:";            //asks for the 2nd number cin>>z;                              //stores 2nd number in var z for(int x=0;x<10;x++)                //a loop to make the code block loop 10 times  { a=a+z; cout<<"this is the result"<< a<<endl;  } cin.get();                          //for some reason in order to make the program stay open cin.get();                          //and not close right after its finished i had to use return 0;                            // cin.get() twice :| }```
this program takes 2 numbers and addts the 2nd number to the first 10 times, each time showing the result.
the problam is i want those 2 numbers to be hex values, if i try to write the value as hex the program crashes, can anyone point me to the right direction? (note: im a newb i love oyur site tutorials :) )
• 07-13-2003
anzas
p.s
sorry for typos :)
• 07-13-2003
anzas
thank you :)
you guys should include it in your tutorial so newbs like me could convert values :x
• 07-14-2003
HybridM
can someone PLEASE update the tutorials with the correct includes!
• 07-14-2003
DougDbug
Something to keep in mind.
Any conversion is done only during input/output.

Everything is actually stored in binary. (Binary input/output is not as straight-forward as decimal/hex/octal.)

This means that once a number is in memory, it's "just a number". You can enter a hex number and a decimal number and then add them together without worrying about their different bases. You can then display the sum in decimal, octal, or hex.