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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started