Clear Filters
Clear Filters

Trying to print a triangle on screen

4 views (last 30 days)
Oskore Mune
Oskore Mune on 3 May 2018
Answered: KSSV on 3 May 2018
I'm trying to print a triangle like this
but i get this
my code works to make the triangle, but i need it flipped. what part of my code do i edit to do this
n=input('How many rows for right justified triangle do you want ');
for i=2:n+1
for j=1:i-1
fprintf('*');
fprintf('');
end
fprintf('\n');
end

Accepted Answer

KSSV
KSSV on 3 May 2018
n=input('How many rows for right justified triangle do you want ');
for i=1:n
str = [blanks(n-i) repelem('*',1,i)] ;
fprintf('%s\n',str) ;
end

More Answers (0)

Categories

Find more on Multidimensional Arrays 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!