Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are required to write a program that takes 10 integer valuesin an array as i

ID: 3618635 • Letter: Y

Question

You are required to write a program that takes 10 integer valuesin an array as input from user. After getting input, the programshould find the elements with repetition and number of times eachelement is repeated.

1. Declare an integer type array.

2. Take input from user in the array i.e. 10 integer values.

3. Pass this array to a function which will calculate anddisplay the number of times an element is repeated.

4. If the array contains elements with repetition, the programshould only display the repeated elements and their count.

5. If there is no repetition in the array, the program shouldsimply display the message “There is no repetition in thearray”.

Sample Output 1

Enter the value of array element 1 : 8

Enter the value of array element 2 : 6

Enter the value of array element 3 : 2

Enter the value of array element 4 : 4

Enter the value of array element 5 : 2

Enter the value of array element 6 : 2

Enter the value of array element 7 : 7

Enter the value of array element 8 : 8

Enter the value of array element 9 : 5

Enter the value of array element 10 : 6

2 is repeated 3 times

6 is repeated 2 times

8 is repeated 2 times

Sample Output 2

Enter the value of array element 1 : 1

Enter the value of array element 2 : 3

Enter the value of array element 3 : 8

Enter the value of array element 4 : 7

Enter the value of array element 5 : 4

Enter the value of array element 6 : 9

Enter the value of array element 7 : 6

Enter the value of array element 8 : 5

Enter the value of array element 9 : 0

Enter the value of array element 10 : 2

There is no repetition in the array

Explanation / Answer

//SZ

#include <iostream>

using namespace std;


int array[10];


voidfill();

boolcheck();

intcounter(int);


intmain()

{

intcount(0);

boolflag = false;

fill();

for(int c(0); flag != true; c++)

{

count = counter(c);

if(count > 1)

{

cout<< c << " is repeated: " << count << "times!" << endl;

}

flag= check();

}

}


voidfill()

{

for(int c(0); c < 10; c++)

{

cout << "Please input a value for element " << c + 1<< ": ";

cin>> array[c];

}

}


boolcheck()

{

booldone = false;

for(int c(0); c < 10; c++)

{

if(array[c] == 0)

{

done= true;

}

else

{

done= false;

}


}

return done;

}


intcounter(int number)

{

int counter(0);

for(int c(0); c < 10; c++)

{

if(array[c] == number)

{

counter++;

}

}

return counter;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote