#Day54 #100DaysChallenge- Matlab Loops|Swapping Numbers
#Day54-Swapping Numbers
Task:
Task:
Write a code to swap three numbers
swap(13,2,7)
After Swap:2,7,13
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those.
Matlab code
swap(13,2,7)
After Swap:2,7,13
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those.
Matlab code
function swapelements(x,y,z)
temp=0;
temp=x;
x=y;
y=z;
z=temp;
fprintf('New X Y Z VALUE %d %d %d',x,y,z);
end
Sample Input and Output
>> swapelements(6,7,8)
New X Y Z VALUE 7 8 6
>> swapelements(13,2,7)
New X Y Z VALUE 2 7 13
Click here for Video Description
Free Codes: youtube.com/castorclasses
No comments