# Find total number of occurrence of a given number using C# program

In this C# program, we will learn, how to find total number of occurrence of a given number? Here we will read an integer array, element to find occurrence of that number.

Given array of integers and we have to find occurrence of a give number.

For example we have list of integers: 10 23 10 24 10

Here we will take a counter initialized with 0. Then take input from console. And check given number to each number of list if item matched. Then we will increase the counter.

Consider the example:

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main()
{
int i       = 0 ;
int count   = 0 ;
int item    = 0 ;

int[] arr1   = new int;

Console.WriteLine("Enter numbers : ");
for (i = 0; i < 5; i++)
{
Console.Write("Element[" + (i + 1) + "]: ");
}

Console.Write("Enter item : ");

for (i = 0; i < 5; i++)
{
if (item == arr1[i])
{
count++;
}
}

Console.WriteLine("Total occurrence of item "+item + " is : "+count);

Console.WriteLine();
}
}
}
```

Output

```Enter numbers :
Element: 10
Element: 20
Element: 30
Element: 10
Element: 50
Enter item : 10
Total occurrence of item 10 is : 2
```

TOP Interview Coding Problems/Challenges

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates