This solution is outdated. To rescore this solution, sign in.
-
2 Comments
Pankaj Soni
on 23 Apr 2016
% correct solution
function triangle(n)
t=n;
clc
if n >1
for l = 1:1:(t-1)
l = l+1;
end
for i=1:1:l
for k = l:-1:i
fprintf(' ');
end
for j = 1:1:i
fprintf('* ');
end
fprintf('\n');
end
else
fprintf(' *\n');
end
Pankaj Soni
on 23 Apr 2016
%please check why this is not compiling
function prac(n)
t=n;
clc
if n >1
for l = 1:1:(t-1)
l = l+1;
end
for i=1:1:l
for k = l:-1:i
fprintf(' ');
end
for j = 1:1:i
fprintf('* ');
end
fprintf('\n');
end
else
fprintf(' *\n');
end
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!