For loop comand use
Mostrar comentarios más antiguos
Hi,I want to compute the sum 2 + 4 + 6 + 8 + 10 + : : : + 100 by using For loop . Can anyone here thankfully help me out?
4 comentarios
James Tursa
el 5 de Oct. de 2017
What have you done so far? What specific problems are you having with your code?
F.O
el 5 de Oct. de 2017
Editada: James Tursa
el 5 de Oct. de 2017
James Tursa
el 5 de Oct. de 2017
Editada: James Tursa
el 5 de Oct. de 2017
Change
total = total + 1;
to
total = total + k; % <-- You need to add the index variable k, not 1 every time
F.O
el 6 de Oct. de 2017
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!