#Day20- #100DaysChallenge- Matlab Loops| Right Angled Triangle:2
#Day20-Right Angled Triangle:2
Task:
Print Right angled Triangle as shown below.Take input from user for number of lines.
*
* *
* * *
* * * *
* * * * *
* * * * * *
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those
Matlab Code:
function rightangledtriangle_2(x)
k=x;
for i=1:1:x
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_2(x)
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
>> rightangledtriangle_2(6)
*
* *
* * *
* * * *
* * * * *
* * * * * *
Click Here for Video Description
Join us on Facebook Group:https://www.facebook.com/groups/matlabcodes
No comments