write statments that will swap the value of two variables A and B. For example:
ID: 3620563 • Letter: W
Question
write statments that will swap the value of two variables A and B. For example:>>A=1;
>>B=2;
>>...........
( your statments here.you can define as many new variables as you want, and you can use as many statments as you want.)
after you statments have been executed, the values of A and B should be swaped.
>>A
A=
2
>>B
B=
1
Explanation / Answer
Dear, Statements to swap two values >>A=1; >>B=2; >>temp=A; >>A=B; >>B=temp; on executing this >>A A= 2 B= 1 For any value inpuuted the function code will be Swapping.m file function y=swapping(A,B) temp=A; A=B B=temp end Function call swapping(2,5) A= 5 B= 2 Hope this will help you..
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.