Cody

Problem 2007. Swap two numbers

Solution 1916604

Submitted on 30 Aug 2019 by Ryan McBurney
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   Pass
aIn = 10; bIn = 20; aOut_correct = 20; bOut_correct = 10; [aOut,bOut] = swapit(aIn,bIn); assert(isequal(aOut, aOut_correct)) assert(isequal(bOut, bOut_correct))

aOut = 20 bOut = 10

2   Pass
aIn = 0; bIn = -3; aOut_correct = -3; bOut_correct = 0; [aOut,bOut] = swapit(aIn,bIn); assert(isequal(aOut, aOut_correct)) assert(isequal(bOut, bOut_correct))

aOut = -3 bOut = 0

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!