How to check for negative number and what is expected output for negative numbers

#include <bits/stdc++.h>
using namespace std;

#define MAX_SIZE 1000005

void SieveOfEratosthenes(vector &primes)
{
bool IsPrime[MAX_SIZE];
memset(IsPrime, true, sizeof(IsPrime));

for (int p = 2; p * p < MAX_SIZE; p++)
{
    if (IsPrime[p] == true)
    {

        for (int i = p * p; i <  MAX_SIZE; i += p)
            IsPrime[i] = false;
    }
}


for (int p = 2; p < MAX_SIZE; p++)
   if (IsPrime[p])
        primes.push_back(p);

}

int main()
{ int n;
vector primes;
cin>>n;
// Function call
SieveOfEratosthenes(primes);

cout << primes[n-1];

return 0;

}

The numbers cannot be -ve since the smallest prime is 2
and the i/p are designed in a way that they do not give out of range values.

So we are not required to be worried of -ve input case

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.