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

Search This Blog

#Day78 #100DaysChallenge- Matlab Loops|Multiplication Table-2

#Day78-Multiplication Table-2

Task:

Write a code to Print Multiplication Table as shown below
9 X 1 = 9
9 X 2 = 18
9 X 3 = 27
9 X 4 = 36
9 X 5 = 45
9 X 6 = 54
9 X 7 = 63
9 X 8 = 72
9 X 9 = 81
9 X 10 = 90

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

Matlab code

function multiplicationtable2(n,m)

for i=1:1:m

    mul=i*n;

    fprintf("%d X %d = %d",n,i,mul);

    fprintf('\n');

end

end

 Sample Input and Output

>> multiplicationtable2(9)

9 X 1 = 9

9 X 2 = 18

9 X 3 = 27

9 X 4 = 36

9 X 5 = 45

9 X 6 = 54

9 X 7 = 63

9 X 8 = 72

9 X 9 = 81

9 X 10 = 90

>> multiplicationtable2(10)

10 X 1 = 10

10 X 2 = 20

10 X 3 = 30

10 X 4 = 40

10 X 5 = 50

10 X 6 = 60

10 X 7 = 70

10 X 8 = 80

10 X 9 = 90

10 X 10 = 100

 Click here for Video description





No comments

Popular Posts

Followers