Search This Blog

#Day39 #100DaysChallenge- Matlab Loops| Alphabet v

#Day39-Alphabet V
Task:
Print alphabet v  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 alphav(x)
k=2*x-2;
for i=1:1:x
    for j=1:1:i
        fprintf('\t');
    end
    fprintf('*')
    for kk=j:1:k
        fprintf('\t');
    end
    fprintf('*')
     k=k-1;
       
    fprintf('\n');
   
end
 Sample Input and Output
>> alphav(7)

* *
* *
* *
* *
* *
* *
**
>> alphav(6)
* *
* *
* *
* *
* *
**
>> alphav(4)
* *
* *
* *
**
Click Here for Video Description





Live Support: t.me/matlabirawen




No comments