#Day38 #100DaysChallenge- Matlab Loops| Alphabet z
#Day38-Alphabet Z
Task:
Task:
Print alphabet z as shown below by taking user input for the number of lines or rows
* * * * * * *
*
*
*
*
* * * * * * *
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those
Matlab code
* * * * * * *
*
*
*
*
* * * * * * *
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those
Matlab code
function alphaz(x)
k=x;
for
i=1:1:x
if i==1||i==x
for j=1:1:x
fprintf('*');
fprintf('\t');
end
else
for j=1:1:k
fprintf('\t');
end
end
fprintf('*');
fprintf('\n');
k=k-1;
end
Sample Input and Output
>> alphaz(5)
* * * * * *
*
*
*
* * * * * *
>> alphaz(6)
* * * * * * *
*
*
*
*
* * * * * * *
Click here for Video Description
Free Codes: youtube.com/castorclasses
No comments