Question: What is wrong with this code? (errors on the bottom of the page) #include #include #include #include using namespace std; int multiply(int a, int b)

What is wrong with this code? (errors on the bottom of the page)

#include #include #include #include using namespace std;

int multiply(int a, int b) { //PUT YOUR CODE HERE //finding the position of rightmost set bit using bitwise right shift operator for second number b int e = -1; while (b) { e++; b = b >> 1; } /ow to multiple two numbers a and b just left shift a by e bits to get the product // like to multiple 5 and 2 // binary representation of 5 = 101 // binary representation of 2 = 010 // position of rightmost set bit in 2 is 1 (positons starting from 0) // so to find product left shift 5 by 1 bit so answer is 1010 whose decimal equivalent is 10 a = a

int main() { int num = 0; int e = 0; printf("Enter an integer: "); scanf("%d", &num); printf("Enter a power of 2 for the second number: "); scanf("%d", &e); int num2 = (int)pow(2, e); printf("the second number is: %d ", num2); int prod = multiply(num, num2); printf("the product from return: %d ", prod); int rprod = num * num2; printf("the product is: %d ", rprod);

return 0;}

What is wrong with this code? (errors on the bottom of the

File Edit View Project Build Debug Test Analyze Tools Extensions Window Help Search (Ctrl+Q) Test1 ML 12 Debug x86 Local Windows Debugger - 2 17 Live Share Tabs (Global Scope) - main Test1 1 2 Test1 Source.cpp* Server Explorer Toolbox #include #include #include #include using namespace std; Solution Explorer BO Search Solution Explorer (Ctrl+;) Solution 'Test1' (1 of 1 project) Test1 - References External Dependencies Header Files Resource Files 12 Source Files ++ Source.cpp Qint multiply(int a, int b) 12 //PUT YOUR CODE HERE //finding the position of rightmost set bit using bitwise right shift operator for second number b int e = -1; while (6) e++; b = b >> 1; /ow to multiple two numbers a and b just left shift a by e bits to get the product // like to multiple 5 and 2 // binary representation of 5 - 101 // binary representation of 2 = 010 // position rightmost set bit in 2 is 1 (positons starting from ) // so to find product left shift 5 by 1 bit so answer is 1010 whose decimal equivalent is 10 a = a

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!