#Day22 #100DaysChallenge- Matlab Loops| Right angled Triangle:4
#Day22-Right Angled Triangle:4
Task:
Print Right angled Triangle as shown below by taking user input for number of lines.
* * * * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
Matlab Code:
function rightangledtriangle_4(x)
k=0;
for i=x:-1:1
k=k+1;
for jj=1:1:k
fprintf('\t');
end
for j=1:1:i
fprintf('\t');
fprintf('*');
end
fprintf('\n');
end
Sample Input and Output
>> rightangledtriangle_4(5)
* * * * *
* * * *
* * *
* *
*
>> rightangledtriangle_4(9)
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
Free Codes: https://www.youtube.com/castorclasses
Free Support: castorclasses2014@gmail.com
Live Support: https://www.t.me/matlabcastor
Like us: https://www.facebook.com/matlabirawen/
Join us: https://www.facebook.com/groups/MATLABcodes
Share with us: https://www.quora.com/q/matlabirawen
No comments