Find the occurrence of an integer in the array in C#
Solution 1:
Output
2 occurenceof 1.
Solution 1:
// C# code for Kth smallest element
// in an array
using System;
class GFG {
// Input array
int[] arr = { 1, 423, 6, 46, 34, 23, 13, 53, 4,1 };
int occ = Convert.ToInt32(Console.ReadLine());
int count = arr.Count(x=>x ==occ);
Console.WriteLine("Total occurenec: "+count);
Console.ReadKey();
}
2 occurenceof 1.
Comments
Post a Comment