Adding hexadecimal # issues

So my method to add hexadecimal numbers together is giving me issues. for my beginning while loop if i have && instead of || ill get the correct answer but the last digit is always left off(the program displays it in backwards order so its actually the first number when the program is running). If i do AB3F9# + d5f4 i get 89ed, missing the "b"....my professor offered me advice by telling me to add a if else statement with two new elements called first and second, if my temp1 pointer is != NULL then we enter the if which would be first = temp1 ->data else first = 0; and same thing for the temp2 pointer. as of now i can only do single digit adding with the || in the first while loop, but if change it to && it works but misses extra digit. If you offer any advice please be very clear as I am only in my second cs class. Thanks below is the code for my "Add method"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  void LList::Add(){
//Pre:the N.O. LList is valid.
//Post: the N.O. LList is still valid, but the list is added together and
//displayed to the user.

	LList Second;
	LList Total;

	listnode * temp1;
	listnode * temp2;
	element carry;//the number that carries over from addition.
	element sum;//the actual total.
	element leftbehind;//the number that is left behind at the bottom.
    element first;
    element second;

	carry = 0;

	Second.ReadBackward();

	temp1 = head;
	temp2 = Second.head;

//this loop is where i change the || to && and it works
	while((temp1 != NULL)||(temp2 != NULL)){

// what my professor told me should fix my problem, what else do i do with
// my new elements named first and second?
        if(temp1 != NULL)
            first = temp1 -> data;
        else
            first = 0;

        if(temp2 != NULL)
             second = temp2 -> data;
		else
            second = 0;


// would anything need to be changed here?
		sum = temp1->data + temp2->data + carry;
		carry = sum/16;
		leftbehind = sum%16;
          temp1 = temp1 -> next;
          temp2 = temp2 -> next;
          Total.InsertTail(leftbehind);
           }

	Steal(Total);

	Print();

	}
Topic archived. No new replies allowed.