Why does the code add up all the elements of the arr
array just by using sum += x
doesn't that mean
" 0 = 0 + x"
?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int[ ] arr = {11, 35, 62, 555, 989};
int sum = 0;
foreach (int x in arr) {
sum += x;
}
Console.WriteLine(sum);
}
}
}