Searching...

Get Number And check it is Prime or Composite?

15:34

#include<iostream>
#include<process.h>
using namespace std;
int main()
{

int num,count=0;
cout<<"Enter a Number to Check prime or not:  ";
cin>>num;
if (num < 0)
{
cout << "Plz Enter +ve Integer Value"<<endl;
exit(1);
}
for(int a=1;a<=num;a++)
{
if(num%a==0)
{
count++;
}
}
if(count==2)
{
cout<<num<<" is a Prime Number. \n";
}
else
{
cout<<num<<" is Composit Number. \n";
}
return 0;
}

0 comments:

Post a Comment

Thanks For Your FeedBack....

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.