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:
- Count each number
- 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?
- If not present and count is greater than or equals to 2 than store it in repeat array.
- If its present than ignore this value
- 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started