Q:

Write a C# program to check if a given number present in an array of numbers

0

Write a C# program to check if a given number present in an array of numbers

Sample Output:

False
True

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 n = 6;
            Console.WriteLine(test(nums, n));
            n = 3;
            Console.WriteLine(test(nums, n));
        }
        public static bool test(int[] arra, int n)
        {
            return arra.Contains(n);
        }
    }
}

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