Solved programming problem

Count Total Duplicate Element in Array in C++.

Source code

#include <iostream>

using namespace std;

int main()

{

    int array[100],i,n,count=0,j;

    cout<<"Please Enter Array Size: "<<endl;

    cin>>n;

    cout<<"Please Enter Array Element: ";

    for(i=0; i<n; i++)

    {

        cin>>array[i];

    }

    for(i=0; i<n; i++)

    {

        for(j=i+1; j<n; j++)

            if(array[i]==array[j]) ///check the value

            {

                array[j] += j +100; ///remove the value

                count++;

            }

    }

    cout<<"
Ans: "<<count<<endl;

   

    return 0;

}

Output

Please Enter Array Size: 5

Please Enter Array Element: 1 3 1 3 1

Ans: 3

Join the discussion

Add your comment

2 previous comments

preally

<a href=http://bestcialis20mg.com/>buy generic cialis online safely</a> As everyone looked at the cbd oil for skin tightening ruins, the vibrations in the ruins became louder cbd oil for skin tightening and louder

opepaygar

Where To Order Legally Amoxicilina Medication In Internet Virginia Qntvhb [url=https://bestadalafil.com/]Cialis[/url] Bwtbfs Reposo Propecia <a href="https://bestadalafil.com/">online cialis</a> https://bestadalafil.com/ - Cialis Xreoeo