Question: The below is an algorithm to add two non-negative integers A and B. A and B are binary numbers. They have been inputted as strings.
The below is an algorithm to add two non-negative integers A and B.
A and B are binary numbers. They have been inputted as strings.
Given the initial values of A and B write an efficient C++ program to find out the number of times the while loop of the algorithm is repeated.
function add(A, B):
while B is greater than 0:
U = A XOR B
V = A AND B
A = U
B = V * 2
return An
Step by Step Solution
3.35 Rating (155 Votes )
There are 3 Steps involved in it
include using namespace std int count string addstring a string b to add t... View full answer
Get step-by-step solutions from verified subject matter experts
