Sunday, 27 November 2011

C++ Program for find prime number


#include<iostream.h>
#include<conio.h>
void main()
 {
   clrscr();
   int n,i,c=0;
   cout<<"Enter any value=";
   cin>>n;
   while(i>0)
    {
 if(n%i==0)
 c++;
 i++;
}

if(c==2)
cout<<"Number is Prime";
else
cout<<"Not prime";
   getch();
 }

No comments:

Post a Comment