0
I do not understand the difference between using for with {} and without {}
As input I used 4 Correct one - https://code.sololearn.com/cIEFJ2Gv1vhO/?ref=app Wrong one - https://code.sololearn.com/czYr0XQ6egSx/?ref=app
4 Respostas
+ 2
{} enclose the code wich run at each iteration...
without {} only the folliwing statement run at each iteration: so, in your codes, with {} you print sum at each iteration, while without, you only print the final value ^^
0
visph Ok, thank you for your answer, I will mark this question as answered in 1 hour. Because I want to hear what the others would say.
0
You got answer already by @visph. Others will also answer same. For clarity you can check code by using
Console.WriteLine(sum);
instead of Console.Write(sum); in your code.
0
With {}, Execute all statements within it.
Without {}, Execute only first statement.