Cody

Problem 2678. Find out sum and carry of Binary adder

Solution 3389173

Submitted on 26 Oct 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
x = 1; y=1; pc=1; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,1)) assert(isequal(carry,1))

Unrecognized function or variable 'carry'. Error in bin_sum_carry (line 2) s = x + y + carry; Error in Test1 (line 4) [sum, carry]=bin_sum_carry(pc,x,y)

2   Fail
x = 1; y=1; pc=0; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,0)) assert(isequal(carry,1))

Unrecognized function or variable 'carry'. Error in bin_sum_carry (line 2) s = x + y + carry; Error in Test2 (line 4) [sum, carry]=bin_sum_carry(pc,x,y)

3   Fail
x = 1; y=0; pc=0; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,1)) assert(isequal(carry,0))

Unrecognized function or variable 'carry'. Error in bin_sum_carry (line 2) s = x + y + carry; Error in Test3 (line 4) [sum, carry]=bin_sum_carry(pc,x,y)

4   Fail
x = 0; y=0; pc=0; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,0)) assert(isequal(carry,0))

Unrecognized function or variable 'carry'. Error in bin_sum_carry (line 2) s = x + y + carry; Error in Test4 (line 4) [sum, carry]=bin_sum_carry(pc,x,y)

5   Fail
x = 1; y=1; pc=0; [sum, carry]=bin_sum_carry(pc,x,y) assert(isequal(sum,0)) assert(isequal(carry,1))

Unrecognized function or variable 'carry'. Error in bin_sum_carry (line 2) s = x + y + carry; Error in Test5 (line 4) [sum, carry]=bin_sum_carry(pc,x,y)

Suggested Problems

More from this Author70

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!