Answers for "in another method display sum of elements in different arrays in c#"

0

in another method display sum of elements in different arrays in c#

using System;
public class funcexer5
  {
    public static int Sum(int[] arr1)
    {
        int tot=0;
        for (int i = 0;i < arr1.Length; i++)
        tot += arr1[i];
        return tot;
    }
    public static void Main()
    {
       int[] arr1 = [5, 5, 6, 4];
       Console.Write("\n\nFunction : Calculate the sum of the elements in an array :\n");  
       Console.Write("--------------------------------------------------------------\n");         
       Console.WriteLine("The sum of the elements of the array is {0}", Sum(arr1));
    }
}
Posted by: Guest on November-02-2020

Code answers related to "in another method display sum of elements in different arrays in c#"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language