Hello so the catch of this problem is you shouldn't use another array or function and do not change the elements of the given array or sort them and we don't know the interval of the elements and side note i shouldn't show the numbers twice
for example if we have a[10]={1,2,1,3,1,5,2,4,3,1} it should print out :
1 --- 4
2 --- 2
3 --- 2
4 --- 1
5 --- 1
I wrote a code for finding the repeating numbers using two for loops but i dont know how to stop it from repeating the same answer and how to make it show the counter
here is the code:
#include<iostream>
using namespace std;
int main()
{
int arr[5];
int size = sizeof(arr) / sizeof(arr[0]);
for (int i = 0; i < 5; i++)
{
cout << "Enter " << i << " number:";
cin >> arr[i];
}
{
for (int i = 0; i < size; i++)
for (int j = i + 1; j < size; j++)
if (arr[i] == arr[j])
cout << " Repeating elements are " << arr[i] << " " << endl;
}
return 0;
}