Hi friends, I want to write a program to add two hexa-decimal numbers. I know there is no way of direction addtion. My logic is, first convert two hexa-numbers into decimal after that we add and finally we have to convert the resultant decimal into hexadecimal. Is it right? Give your suggestion.
Hexa Decimal Addition in C
Collapse
X
-
Tags: None
-
I may be wrong, but I know hexadecimal numbers can be decalred 0x0f45 (for example, and stored as integers so I would imagine you can add them and do all sorts of things. I'm pretty sure when you are using printf to print to the screen, you can manipulate %d to display hexadecimal values -
information is stored within the computer in binary and converted into decimal, octal or hex notation when we input and output numeric data. e.g. in to print a value in hexOriginally posted by sarchanakumarHi friends, I want to write a program to add two hexa-decimal numbers. I know there is no way of direction addtion. My logic is, first convert two hexa-numbers into decimal after that we add and finally we have to convert the resultant decimal into hexadecimal. Is it right? Give your suggestion.
and in C++Code:int i=0x02F4B; printf("i in hex %#0x\n", i);
when run both giveCode:int i=0x02F4B; cout << "i in hex " << setiosflags(ios::showbase) << hex << i << endl;
i in hex 0x2f4b
similar conversion is used to input data in hexComment
Comment