Search This Blog

#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
 Sample Input and Output
>> 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






Live Support: t.me/matlabirawen




No comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();