Beginner programmer here can someone please explain to me how this loop works. How can the loop detect the duplicate element in the array? sorry for the simple question.
#include <iostream>
using namespace std;
int main()
{
    int num[5];
    int numSize = sizeof(num) / sizeof(num[0]);
    for(int i = 0; i < numSize; i++)
    {
        cout << "Enter number : ";
        cin >> num[i];
        if(i >= 0)
        {
            for(int j = 0 ; j < numSize; j++)
            {
                if(num[i] == num[j] && (i != j))
                {
                    i--;
                    j++;
                }
            }
        }
    }
    for(int p = 0; p < numSize; p++)
        cout << num[p] << " ";
}
 
    