← Back to Question List
C# Code Walkthrough #40
Summing an Array With foreach
📄 Code
Read carefully — what does this print?1int[] nums = { 4, 8, 15, 16, 23, 42 };2int total = 0;3foreach (int n in nums)4{5 total += n;6}7Console.WriteLine(total);