Write a C# Sharp program to compute the sum of values in a given array of integers except the number 17. Return 0 if the given array has no integer
- برمجة سي شارب
- برمجة
- 2021-05-17
- MarwaMohammed
الأجوبة
using System;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Sum of values in the array of integers except the number 17: ");
Console.WriteLine(test(new[] { 1, 5, 7, 9, 10, 17 }));
}
static int test(int[] nums)
{
int sum = 0;
for (int i = 0; i < nums.Length; i++)
{
if (nums[i] != 17) sum += nums[i];
}
return sum;
}
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
