We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Wednesday, May 20, 2015

Write a program in C# count the duplicate Numbers?


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication1

{
class Program


{
static void Main(string[] args)


{
int[] array = { 10,15,6,6,5, 10, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 11, 12, 12 };


int count = 1;

for (int i = 0; i < array.Length; i++)

{
for (int j = i; j < array.Length - 1; j++)


{
if (array[j] == array[j + 1])


count = count + 1;

} 
Console.WriteLine("\t\n " + " Number of Duplecate value:" + " " + count);


Console.ReadLine();

}

}

}

}

Output:

 
 


No comments: