multiplication table using for loops

2 visualizaciones (últimos 30 días)
El-Hassani Ali
El-Hassani Ali el 14 de Mzo. de 2021
Respondida: Matt J el 14 de Mzo. de 2021
hi , i need a script using for loop and nested one i guess to show this multiplication table, in this order particulary
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
  2 comentarios
James Tursa
James Tursa el 14 de Mzo. de 2021
What have you done so far? What specific problems are you having with your code?
El-Hassani Ali
El-Hassani Ali el 14 de Mzo. de 2021
x=input('enter number of rows in table: ');
for i=1:x
fprintf('%d\n',i)
end
i've done this so far and idk how to update my variables

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 14 de Mzo. de 2021
for i=1:5
i*(1:i)
end
ans = 1
ans = 1×2
2 4
ans = 1×3
3 6 9
ans = 1×4
4 8 12 16
ans = 1×5
5 10 15 20 25

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by