What part of my code do i change to print my triangle flipped?
2 views (last 30 days)
Show older comments
Oskore Mune
on 4 Jun 2018
Answered: Kodavati Mahendra
on 5 Jun 2018
Hey so i am trying to print this triangle
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191012/image.png)
, but I only got this far
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191013/image.png)
What do I need to change in my code in order to flip it?
n=input('Enter rows for left triangle');
for i=2:n+1
for j=1:i-1
fprintf('*');
fprintf('');
end
fprintf('\n');
end
0 Comments
Accepted Answer
Kodavati Mahendra
on 5 Jun 2018
n=input('Enter rows for left triangle\n');
for i=1:n
for j=1:i
x(i,j) = '*';
end
end
disp(fliplr(x));
0 Comments
More Answers (0)
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!