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

OK thats your homework, but what is your question?

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

#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;
}
Comments
Just stop.

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

This article has been dead for over six months. Start a new discussion instead.