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

Search This Blog

#Day37 #100DaysChallenge- Matlab Loops| Alphabet I

#Day37-Alphabet I
Task:
Print alphabet I 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 alphai(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:ceil(x/2)
                    fprintf('\t');
                end
                   
    end
    fprintf('*');
    fprintf('\n');
end
                   
Sample Input and Output
>> alphai(12)

* * * * * * * * * * * * *
*
*
*
*
*
*
*
*
*
*
* * * * * * * * * * * * *
>> alphai(6)
* * * * * * *
*
*
*
*
* * * * * * *
Click Here for Video Description





Live Support: t.me/matlabirawen



No comments

Popular Posts

Followers