Tuesday, 22 December 2015

WRITE A PROGRAM THAT INPUT AN ARRAY OF 10 INTEGERS AND TELLS HOW MANY PROME NUMBERS ARE THERE IN THIS ARRAY.

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int num,p=0,count=0;
int array[10]={1,2,3,4,5,6,7,8,9,10};
for(int a=0; a<10; a++)
{
for(int c=2;c<=array[a]/2;c++)
{if(array[a]%c==1)
 {
 p=1;
 break;}}
 if(p==0)
 count++;}
 cout<<"PRIME NUMBERS IN ARRAY ARE "<<count;
 getch();

}

3 comments: