Problem Statement: Finding the repeated elements in an array
You are required to write a program that takes 10 integer values in an array as input from user. After getting input, the program should find the elements with repetition and number of times each element is repeated.


Detailed Description:

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 and display the number of times an element is repeated.
4. If the array contains elements with repetition, the program should only display the repeated elements and their count.
5. If there is no repetition in the array, the program should simply display the message “There is no repetition in the array”.

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

Recommended Answers

All 11 Replies

OK thats your homework, but what is your question?

OK thats your homework, but what is your question?

My question is that how to make like this?this is my assignment.

please solve it and give me logic for it.

Are you going to use my code to pass your course?

No I am just wanting help to learn logic and also want code

We don't write code for people. We help you fix your code.

Member Avatar for iamthwee

>please solve it and give me logic for it.

I think that says it all.

please answer my question please

Member Avatar for iamthwee

No amount of begging is going to change anything. . .

#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{	
	int number[10];
	int times[10]={1,1,1,1,1,1,1,1,1,1};
	int i,j;
	bool bRep = 0;
	for (i=0; i<10; i++)
	{
		
		cout << "\ninput number ";
		cin >> number[i];
		
		
		
	}
	for (i=0; i<10; i++)
	{	if (times[i] == 1)
		{	
			for (j =i+1; j<10; j++)
			{
				if (number[i] == number[j])
				{
					times[i]++;
					times[j]=times[i];
					bRep =1;
				}
			}
			if (times[i] > 1)
				cout << "\n" << number[i] << " is repeated " << times[i]<<"\n";
		}
		
	}
	if (!bRep)
		cout << "\nThere is no repetition in the array\n";

	system ("PAUSE");
	return 0;
}
commented: Just stop. -2

refer counting sort.. its bit similar to this.. if u want the logic.. u can refer to tat...:icon_lol:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.