Friday, 27 July 2012

how to find prime number using c++


 This is the source code for finding prime number 
#include<iostream.h>
#include<conio.h>
main()
{
      int n,d,p=1;
      cout<<"enter the number?";
      cin>>n;
      d=2;
      while(d<=n/2)
      {
                   if(n%d==0)
                   p=0;
                   d++;
                   }
                   if(p==0)
                   cout<<"not prime number";
                   else
                   cout<<"prime number";
                   getch();
                   }
      End

1 comment:

  1. thank you for sharing nice article in your blog
    visit
    web tutorial programming
    welookups

    ReplyDelete