Recursive sum method

image_pdfimage_print

public class SumPrices {

public static double Sum(double[] p, int start, int end) {
if (start < end) return p[start] + Sum(p,start+1,end); else return 0; } public static void Main() { double[] prices = {1.3, 13.68, 314.919, 82.827, 363.949}; System.Console.WriteLine("The sum is {0:C}", Sum(prices,0,prices.Length)); } } [/csharp]