#Day10- #100DaysChallenge- Matlab Loops| Printing Alphabet Pattern E and F
#Day10- Printing Alphabet Pattern E and F
Task:Print the alphabets E and F using any special character,numeric or Alphabets,The length and width of the pattern should be same and given during the function start, along with that value the character with which the pattern is printed should also be given
Use Switch case for two cases E and F if it is other then print the message as"only alphabets E and F are printed in this function".
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those
E pattern using Special Character
@@@@@@@@@
@
@
@@@@@@@@@
@
@
@
@@@@@@@@@
F pattern using Alphabet
g
g
ggggggggg
g
g
g
g
Matlab Code:
function alphbet_e_f(p,y,x)
switch x
case 1
for i=1:1:p
for j=1:1:p
if i==1 || i==p ||i==floor(p/2)
fprintf(y);
end
end
fprintf(y);
fprintf('\n');
end
case 2
for i=1:1:p
for j=1:1:p
if i==1 || i==floor(p/2)
fprintf(y);
end
end
fprintf(y);
fprintf('\n');
end
otherwise
disp('Only Alphabets E and F are printed in this function');
end
end
Sample Input and Output
alphbet_e_f(18,'@',8)
Only Alphabets E and F are printed in this function
>> alphbet_e_f(8,'@',1)
@@@@@@@@@
@
@
@@@@@@@@@
@
@
@
@@@@@@@@@
>> alphbet_e_f(8,'4',2)
444444444
4
4
444444444
4
4
4
4
Click Here for video Description
Join us on Telegram: https://t.me/matlabirawen
Join us on Facebook Group:https://www.facebook.com/groups/matlabcodes
No comments