Delivered by FeedBurner

New Answers in your Inbox

Showing posts with label Doubly Linked List. Show all posts
Showing posts with label Doubly Linked List. Show all posts

Adding two integers-CS 62December-1999

Q.1.(a) Write a routine in C for adding two integers represented by doubly linked lists.
Answer: NODEPTR addint (NODPTR p, NODEPTR q)
{
/* check if integers are of like sign */
if(p->info * q ->info >0)
return (addsame(p,q));
/* check which has a larger absolute value */
if(compabs(p,q)>0)
return (addiff(p,q));
else
return (addiff(q,p));
}