Question: 1. Multiply 2 bigNum in stack. My code is half done but it did not show the right result. Could you please fix it? Thank

1. Multiply 2 bigNum in stack. My code is half done but it did not show the right result. Could you please fix it? Thank you.

bigNumber multiply (const bigNumber& opd2) const

{

int multiply = 0;

int carryNum = 0;

bigNumber results;

bigNumber addition("0");

node* ptr1 = this->head;

node* ptr2 = opd2.head;

while (ptr1 != null)

{

while (ptr2 != null)

{

multiply = ptr1->data + ptr2->data + carryNum;

int num = multiply % 10;

carryNum = multiply / 10;

result.addLast(num);

ptr2 = ptr2->next;

}

if (carryNum > 0)

{

result.addLast(carryNum);

}

ptr1 = ptr1->next;

addition = addtion.add(results);

}

return addtion;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!