// Diplaying Prime Numbers from array
// Programmer name: Sohail Ahmed
// Dated: 16/05/2011
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
int prime[5]={1,3,5,7,9};
void main()
{
clrscr();
int n_div;
int divisor;
for(int count=0; count<=5; count++)
{
n_div=0;
divisor=1;
while(divisor<=prime[count])
{
if(prime[count]%divisor==0)
{
n_div++;
}
divisor++;
}
if(n_div==2)
{
cout<<prime[count]<<" ";
}
}
getch();
}
0 comments:
Post a Comment