Code:

int main()
{
int N, C;
cout<<"Enter an integer ";
cin>>N;
C=2;
while(N>C*C&&N%C!=0)
{
C=C+1;
}
if(N>=C*C)
cout<<"NOT PRIME"<<endl;
else
cout<<"PRIME"<<endl;
system("PAUSE");
return 0;
}

This is the code which finds the integer if its prime or not. But i need to do something different. I will enter 15 integers and the program will print only the prime ones.

I have coded this but didn't work.

Code:

int main()
{
int A[15];
int N, C;
for(N=0;N<15;N=N+1)
{
cout<<"Enter "<<N+1<<". value: ";
cin>>A[N];
}
cout<<"--------"<<endl;
C=2;
while(N>C*C&&N%C!=0)
{
C=C+1;
}
if(N>=C*C)
{
cout<<A[N]<<endl;
}
system("PAUSE");
return 0;
}

Can anyone help me how can i do this program.