Monday, December 7, 2009

C++->PRIME NUMBERS

Find the prime numbers between 1 and 100

#include

#include

#include

void main()

{

int i,j,n,p;

clrscr();

int flag;

for(i=1;i<=100;i++)

{

p=i;

flag=1;

for(j=2;j<=p/2;j++)

if((p%j)= = 0)

{

flag=0;

break;

}

if(flag= = 1)

cout<
}

getch();

}

0 comments:

Post a Comment

Followers