How is this solution even failing :o

The question was to calculate whether a num is prime

my soln

‘’’
#include

using namespace std;

void isPrime(int a){

int prime[a];

prime[0]=0;

prime[1]=0;

for (int i = 2; i <= a; i++){

    prime[i]=1;

}

for(int i=2;i*i<=a;i++){

    if(prime[i]==1){

        for (int j=i*i;j<=a;j+=i){

           prime[j]=0;

        }

    }

}

if(prime[a] == 1){

    cout << "YES\n"; 

}

else{

    cout << "NO\n";

}

}

int main(){

int t;  cin >> t;

while(t--){

    int n;  cin >> n;

    isPrime(n);

}

return 0;

}

Please Format your code.