Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions