#Day37 #100DaysChallenge- Matlab Loops| Alphabet I
#Day37-Alphabet I
Task:
Task:
Print alphabet I 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 alphai(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:ceil(x/2)
fprintf('\t');
end
end
fprintf('*');
fprintf('\n');
end
Sample Input and Output
>> alphai(12)
* * * * * * * * * * * * *
*
*
*
*
*
*
*
*
*
*
* * * * * * * * * * * * *
>> alphai(6)
* * * * * * *
*
*
*
*
* * * * * * *
Click Here for Video Description
Free Codes: youtube.com/castorclasses
No comments