#Day24- #100DaysChallenge- Matlab Loops| Inverted Triangle
#Day24-Inverted Triangle
Task:
Print Inverted Triangle by taking input form user for number of rows.
Example:
Inverted Triangle of 5 rows:
* * * * *
* * * *
* * *
* *
*
Matlab Code:
function inverted_triangle(x)
k=1;
for i=x:-1:1
for hh=1:1:k
fprintf('\t');
end
for j=1:1:i
fprintf('\t');
fprintf('*');
fprintf('\t');
end
k=k+1;
fprintf('\n');
end
Sample Input and Output
>> inverted_triangle(4)
* * * *
* * *
* *
*
>> inverted_triangle(2)
* *
*
>> inverted_triangle(3)
* * *
* *
*
Click Here for Video Description
Join us on Telegram: https://t.me/matlabcastor
Join us on Facebook Group:https://www.facebook.com/groups/matlabcodes
No comments