For loop comand use
Afficher commentaires plus anciens
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 commentaires
James Tursa
le 5 Oct 2017
What have you done so far? What specific problems are you having with your code?
F.O
le 5 Oct 2017
Modifié(e) : James Tursa
le 5 Oct 2017
James Tursa
le 5 Oct 2017
Modifié(e) : James Tursa
le 5 Oct 2017
Change
total = total + 1;
to
total = total + k; % <-- You need to add the index variable k, not 1 every time
F.O
le 6 Oct 2017
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!