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
- برمجة سي شارب
- برمجة
- 2021-05-15
- MarwaMohammed
الأجوبة
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;
}
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال