Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

#Day91#100DaysChallenge- Matlab Loops | Steps Pattern

#Day91-Steps Pattern

Task:

Write a code for Steps Pattern as shown below.Get user Input for number of rows
*****
*****
*****
*****
*****

Note: This code can be done using the in-built command. But for the challenge, I am trying to avoid those.

Matlab code

function stepspattern(x)

 

count=1;

for i=1:1:x

    for count=1:1:count

        fprintf('\t');

    end

        for j=1:1:x

            fprintf('*');

        end

            fprintf('\n');

            count=count+1;

          

end



Sample Input and Output

>> stepspattern(6)
******
******
******
******
******
******
>> stepspattern(5)
*****
*****
*****
*****
*****

Click here for video description

No comments

Popular Posts

Followers