#Day26 #100DaysChallenge- Matlab Loops| Printing Alphabet-k and Less than symbol
#Day26-
Printing Alphabet-k and Less than symbol
Task:
Print Alphabet k and less than symbol by taking user input
for number of lines or rows
>>
alphabet_k(7)
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
>> alphabet_k(7)
@
@
@
@
@
@
@
@
@
@
@
@
@
@
Note:
This code can be done using the in-built command. But for the challenge, I am
trying to avoid those
Matlab code
function alphabet_k(x)
k=x;
for i=1:1:x
%fprintf('@')
for j=1:1:k
fprintf('\t')
end
k=k-1;
fprintf('@')
fprintf('\n');
end
k=1;
for i=x:-1:1
%fprintf('@')
for j=1:1:k
fprintf('\t')
end
k=k+1;
fprintf('@')
fprintf('\n');
end
end
Sample Input and Output
>> alphabet_k(5)
@
@
@
@
@
@
@
@
@
@
>> alphabet_k(5)
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
@ @
>>Note:Take off % for printing K
No comments