// 2nd Logic To check prime or composite
#include <iostream>
#include <process.h>
using namespace std;
int main()
{
int n,counter=0;
cout << "Enter Any +ve Integer: ";
cin >> n;
if (n < 0)
{
cout << "STOP !!!! Plz Enter Correct Number Value."<<endl;
exit(1);
}
for (int j=2;j<=n/2;j++)
{
if (n%j==0)
{
counter++;
break;
}
}
if (counter==0 && n!=0)
cout << n << " is a Prime Number.\n";
else
cout << n << " is a Composite Number.\n";
return 0;
}
#include <iostream>
#include <process.h>
using namespace std;
int main()
{
int n,counter=0;
cout << "Enter Any +ve Integer: ";
cin >> n;
if (n < 0)
{
cout << "STOP !!!! Plz Enter Correct Number Value."<<endl;
exit(1);
}
for (int j=2;j<=n/2;j++)
{
if (n%j==0)
{
counter++;
break;
}
}
if (counter==0 && n!=0)
cout << n << " is a Prime Number.\n";
else
cout << n << " is a Composite Number.\n";
return 0;
}
0 comments:
Post a Comment
Thanks For Your FeedBack....