Q:

Write a C# Sharp program to multiply all of elements of a given array of numbers by the array length

0

Write a C# Sharp program to multiply all of elements of a given array of numbers by the array length

Sample Output:

5
15
25
35
45

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Linq;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = { 1, 3, 5, 7, 9 };
            int[] new_nums = test(nums);
            Array.ForEach(new_nums, Console.WriteLine);
        }
        public static int[] test(int[] nums)
        {
             var arr_len = nums.Length;
             return nums.Select(el => el * arr_len).ToArray();
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now