i got this prime no. code for analysis. and i hav not been able to understand it completely.
#include<iostream.h>
#include<conio.h>
void main()
{
int x, y, c = 0;
clrscr();
cout<<"\nPrime Numbers upto 100 :\n ";
for( x = 2; x < 100; x++ )
{
if( x % 2 != 0 || x == 2 )
{
for( y = 2; y <= x / 2; y++ )
{
if( x % y == 0 )
{
break;
}
}
if( y > x / 2 )
{
cout<<"\n\t" <<x ;
c++;
}
}
}
cout<< "\n \nTotal Prime No.: " << c ;
getch();
}
Now, what i understood is that ,
- x is used to generate a list of 100 nos.
- the first 'if' condition is used to select only ODD no.
i really dont get the rest of the program ,
Please help. :-|
thnx for reading the post.