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

Search This Blog

#Day38 #100DaysChallenge- Matlab Loops| Alphabet z

#Day38-Alphabet Z
Task:
Print alphabet z  as shown below by taking user input for the 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 alphaz(x)
k=x;
for i=1:1:x
    if i==1||i==x
        for j=1:1:x
            fprintf('*');
            fprintf('\t');
        end
    else
                for j=1:1:k
                    fprintf('\t');
                end
                   
    end
    fprintf('*');
    fprintf('\n');
    k=k-1;
end

Sample Input and Output
>> alphaz(5)

* * * * * *
*
*
*
* * * * * *
>> alphaz(6)
* * * * * * *
*
*
*
*
* * * * * * *
Click here for Video Description





Live Support: t.me/matlabirawen




                                       

No comments

Popular Posts

Followers