34.1k views
3 votes
write a program that input ten integers in an array and counts all prime numbers entered by the user. the program finally display total number of primes in array.

User MichaelH
by
3.7k points

1 Answer

3 votes

Answer:

int main ()

{

int arr[10], i, p=0, c, prime=0;

for(i=0;i<10;i++)

{

cout<<"Enter an integer:";

cin>>arr[i];

}

cout<<"The prime numbers are:\\";

for(i=0;i<10;i++)

{

if(arr[i]>1)

{

p=1;

for(c=2;c<arr[i];c++)

{

if(arr[i]%c==0)

{

p=0;

break;

}

}

}

if(p==1)

{

cout<<arr[i]<<" is a prime number.\\";

prime++;

}

}

cout<<"total prime numbers entered by the user are: "<<prime;

}

Step-by-step explanation:

this should be good

User Artworkjpm
by
3.1k points