#Day8- #100DaysChallenge- Matlab Loops| Printing Special Character Pattern-Part-2
#Day8- Printing Special Character Pattern-Part-2
Task: Print the given character (maybe special character or alphabets or numeric) for the given number of times diagonally from right to left.
Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those
Example: special_character_pattern_diag(6,'k')
k
k
k
k
k
Matlab Code:
function special_character_pattern_diag(x,y)
%x
=Number of lines
%y  character like * & ^ % $ # @ ! or any
numeric or aplhabets with in ''
for i=x:-1:2
    for j=i-1:-1:1
        fprintf('\t')
    end
    fprintf(y)
    fprintf('\n')
end
Sample Input and Output:
>> special_character_pattern_diag(6,'#')
     #
    #
   #
  #
 #
>> special_character_pattern_diag(6,'6')
     6
    6
   6
  6
 6
>> special_character_pattern_diag(6,'k')
     k
    k
   k
  k
 k
>> special_character_pattern_diag(10,'o')
         o
        o
       o
      o
     o
    o
   o
  o
 o
Click Here for Video Description
Join us on Telegram:https://t.me/matlabirawen Join us on Facebook Group: https://www.facebook.com/groups/matlabcodes
 
 
 
 
 
 
 
%206th%20Edition,%20Kindle%20Edition.jpg) 
 
 
 Posts
Posts
 
 
 
 
 
 
 
 
No comments