#Day72 #100DaysChallenge- Matlab Loops| Character Pattern
#Day72-Character Pattern
Task:
Write a code to Print Character in a pattern as shown below
A
BC
DEF
GHIJ
KLMNO
ABCDE
FGHI
JKL
MN
O
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those.
Matlab code
function charactertriaangle(charc,n)
charc_copy=charc;
for i=1:1:n
for j=i:-1:1
fprintf('%c',charc);
charc=charc+1;
end
fprintf('\n');
end
charc=charc_copy;
for i=n:-1:1
for j=i:-1:1
fprintf('%c',charc);
charc=charc+1;
end
fprintf('\n');
end
>> charactertriaangle('A',5)
A
BC
DEF
GHIJ
KLMNO
ABCDE
FGHI
JKL
MN
O
>> charactertriaangle('A',7)
A
BC
DEF
GHIJ
KLMNO
PQRSTU
VWXYZ[\
ABCDEFG
HIJKLM
NOPQR
STUV
WXY
Z[
\
Click here for Video Description
Free Codes: youtube.com/castorclasses
No comments