I have a while statement that is breaking when only one of the two conditions is true.

Thewhile loopsuppose to be breaking when thetwo conditions are metandnot only one.

suppose hp_p= 1 ,2 ,3

hp_q= 1,2, null

when hp_p = 3 and hp_q = null it suppose to keep going, but instead it breaks. WHY?

Code:`while((hp_p!=NULL) && (hp_q!=NULL))`

{

current = (struct integer *) malloc (sizeof( struct integer ));

if(hp_p!=NULL && hp_q==NULL)

{

d= hp_p->digit + r;

if(d>9){d=d-10;r=1;}else{r=0;}

hp_p = hp_p->next;

}

if(hp_p==NULL && hp_q!=NULL)

{

d= hp_q->digit + r;

if(d>9){d=d-10;r=1;}else{r=0;}

hp_q = hp_q->next;

}

if(hp_p!=NULL && hp_q!=NULL)

{

d= hp_p->digit + hp_q->digit + r;

if(d>9){d=d-10;r=1;}else{r=0;}

hp_q = hp_q->next;

hp_p = hp_p->next;

}

current->digit = d;

current->next = result;

result = current;

}