c++ prime number program source code
void main()
{
int n,i,flag=0;
clrscr();
cout<<"enter the number=";
cin>>n;
for(i=2;i<n/2;i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
if(flag==0)
cout<<"number is prime number=";
else
cout<<" number is not prime =";
}
c++ prime number program source code
void main()
{
int n,i,flag=0;
clrscr();
cout<<"enter the number=";
cin>>n;
for(i=2;i<n/2;i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
if(flag==0)
cout<<"number is prime number=";
else
cout<<" number is not prime =";
}
c++ prime number program source code
0 comments: