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

Search This Blog

#Day28 #100DaysChallenge- Matlab Loops| HollowRightangledTriangle


#Day28-HollowRightangledTriangle
Task:
Print Hollow Right angled Triangle as shown below by taking user input for 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

function hollowrightangledtriangle(x)
for i=1:1:x
    fprintf('*');
    for j=1:1:i
        fprintf('\t');
    end
        fprintf('*');
        fprintf('\n');
end
        for i=1:1:x+1
            fprintf('*');
            fprintf('\t');
           
        end
end

 Sample Input and Output
>> hollowrightangledtriangle(10)
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* * * * * * * * * * * >> 
>> hollowrightangledtriangle(7)
* *
* *
* *
* *
* *
* *
* *
* * * * * * * *

Click here for video Description





Live Support: t.me/matlabirawen



MATLAB Book for the beginner: https://amzn.to/3fTfmTa

No comments

Popular Posts

Followers