Q:

Write a C# Sharp program to check whether the average value of the elements of a given array of numbers is a whole number or not

0

Write a C# Sharp program to check whether the average value of the elements of a given array of numbers is a whole number or not

Sample Output:

Check the average value of the said array is a whole number or not: True
Check the average value of the said array is a whole number or not: False

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, 2, 3, 5, 4, 2, 3, 4 };
            Console.WriteLine("Check the average value of the said array is a whole number or not: " + test(nums));
            int[] nums1 = { 2, 4, 2, 6, 4, 8 };
            Console.WriteLine("Check the average value of the said array is a whole number or not: " + test(nums1));
        
        }
        public static bool test(int[] arr_nums)
        {
            return arr_nums.Average() % 1 == 0;
        }
    }
}

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