Question: You are given code of C++ in the end of this file. In this task we try to find out numbers that repeats two or

You are given code of C++ in the end of this file. In this task we try to find out numbers that repeats two or more times. You are given a code and output for different arrays. Your task is to complete the code.

Logic for completion of Code should be according to following:

  1. Count each number
  2. Create array called repeat array that contains number that are repeated. After counting you should check whether this number is already present in array of not?
  3. If not present and count is greater than or equals to 2 than store it in repeat array.
  4. If its present than ignore this value
  5. In the end print the repeat array

Note: You cannot delete code from given file, but off course you can shuffle code or add new code in it.

#include

using namespace std;

int main()

{

const int size=10;

int arr[size]={2,3,4,1,11,3,2,178,43,76};

int repeat[size];//array that stores repeated elements

int curr=0;// variable to show current position of repeat array. In strart its zero

for(int i=0;i

{

//count number of time arr[i] value is present in array

int count=0;

for(int j=0;j

{

}

//check whether arr[i] is already present in repeat array or not

bool flag=true;

for(int k=0;k<=curr;k++)

{

//add code here

}

//check if count is greater than 2 and flag is also true(number not in repeat)

//than add it into repeat array.

if(count>=2&&flag)

{

//add code here

}

}

//print repeat array

for(int k=0;k

cout<

return 0;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!