+ 1
I'm not sure if the lessons went over how to output the sum of a for loop in C#. Can anyone explain?
The lessons haven't gone over while loops so I figure it wants a different answer.
3 Réponses
+ 2
You make viariable, give it a condition and increment or decrement variable untill condition doesn't meet requirements, in code it looks like this:
for (int i = 0; i < 10; i++)
+ 1
I got it!!!
I had to end the statement with with a formula to output the sum. It was more than I first thought.
for(int i = 1; i <= 10; i++)
sum = sum + i;
0
Then how would we output sum of all numbers generated?