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

Search This Blog

#Day17- #100DaysChallenge- Matlab Loops| Numeric Pattern

#Day17-Numeric Pattern

Task: Print Numeric Pattern as shown below. Get user input for the number of lines to be printed.
Example for 8 line pattern:

1
22
333
4444
55555
666666
7777777
88888888

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

Matlab Code:


function numeric_patter(x)
k=1;
for i=1:1:x
    for j=1:1:i
        fprintf('%d',k);
    end
    k=k+1;
    fprintf('\n');

end

Sample Input and Output:
>> numeric_patter(9)
1
22
333
4444
55555
666666
7777777
88888888
999999999
>> numeric_patter(4)
1
22
333
4444
>> numeric_patter(6)
1
22
333
4444
55555
666666
>> numeric_patter(3)
Click here for video Description



Join us on Telegram: https://t.me/matlabirawen 
Join us on Facebook Group:https://www.facebook.com/groups/matlabcodes


No comments

Popular Posts

Followers