Thursday 21 February 2013

WAP to check a number is prime or not!

| |




 




#include<iostream>
#include<string>


using namespace std;
int main()
{
   
    int  n,x,f;

    cout<<"Enter The Number "<<endl;
cin>>x;


int  count=0;
f=x;


while(f!=0)
{
           if(x%f==0)
           {count=1+count;}
           f=f-1;
           }
           if(count==2)
           {cout<<x<<" is Prime"<<endl;}
           else
          { cout<<x<<" is not prime"<<endl;}
         
            
system("pause");
return 0;
}
 

WAP to check a number is prime or not!


Related Posts Plugin for WordPress, Blogger...
Powered by Blogger.