Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions