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

Search This Blog

#Day21 #100DaysChallenge- Matlab Loops| Right angled Triangle:3

#Day21-Right Angled Triangle:3

                   

Task:

Print Right angled Triangle as shown below by taking user input for number of lines.


                *             *             *             *             *             *             *             *             *

                *             *             *             *             *             *             *             *

                *             *             *             *             *             *             *

                *             *             *             *             *             *

                *             *             *             *             *

                *             *             *             *

                *             *             *

                *             *

                *

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

MATLAB code

function rightangledtriangle_3(x)

 

for i=x:-1:1

    for j=1:1:i

        fprintf('\t');

        fprintf('*');

    end

        fprintf('\n');

end

       

 

Sample Input and Output

rightangledtriangle_3(9)

                *             *             *             *             *             *             *             *             *

                *             *             *             *             *             *             *             *

                *             *             *             *             *             *             *

                *             *             *             *             *             *

                *             *             *             *             *

                *             *             *             *

                *             *             *

                *             *

                *

>> rightangledtriangle_3(10)

                *             *             *             *             *             *             *             *             *             *

                *             *             *             *             *             *             *             *             *

                *             *             *             *             *             *             *             *

                *             *             *             *             *             *             *

                *             *             *             *             *             *

                *             *             *             *             *

                *             *             *             *

                *             *             *

                *             *

                *

 Free Codes: youtube.com/castorclasses

Free Support: castorclasses2014@gmail.com

Live Support: www.t.me/matlabirawen

Like us: https://www.facebook.com/matlabirawen/

Join us: https://www.facebook.com/groups/MATLA...

Share with us: https://www.quora.com/q/matlabirawen

No comments

Popular Posts

Followers