MATLAB Answers

code in script called swap

21 views (last 30 days)
Jose Morales
Jose Morales on 24 Jan 2020 at 23:10
Answered: James Tursa on 25 Jan 2020 at 0:08
write a few lines of code that swap the values of x and y. Put your code in a script called swap and test it.

  4 Comments

Show 1 older comment
Jose Morales
Jose Morales on 24 Jan 2020 at 23:39
I just have the script
>> swap
If it works properly it should work like this:
>> x = 1, y = 2
x = 1
y = 2
>> swap
>> x, y
x = 2
y = 1
James Tursa
James Tursa on 24 Jan 2020 at 23:46
Do you have any ideas for how to do this? What would the algorithm be?
Jose Morales
Jose Morales on 24 Jan 2020 at 23:50
I do not. I'm new to this and I'm confused just as you are. Here's the full question:
To test your understanding of assignment statements, write a few lines of code that swap the values of x and y. Put your code in a script called swap and test it

Sign in to comment.

Answers (1)

James Tursa
James Tursa on 25 Jan 2020 at 0:08

  0 Comments

Sign in to comment.

Sign in to answer this question.