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

Search This Blog

#Day31 #100DaysChallenge- Matlab Loops| Printing Alphabet 'O'

#Day31-Printing Alphabet 'O'
 Task:
Print alphabet 'O' 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 printingalphao(x)
for i=1:1:x
    if i==1||i==x
        for j=1:1:floor(x/2)
            fprintf('\t');
            fprintf('*');
        end
    else
            fprintf('*');
            for j=1:1:floor(x/2)+1
                fprintf('\t');
            end
                fprintf('*');
    end
                fprintf('\n');
end
end
               
  Sample Input and Output
>> printingalphao(7)
* * *
* *
* *
* *
* *
* *
* * *
>> printingalphao(10)
* * * * *
* *
* *
* *
* *
* *
* *
* *
* *
* * * * *
Click here for video description





Live Support: t.me/matlabirawen



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


No comments

Popular Posts

Followers