A)
#include <iostream>
using namespace std;
int main() {
cout<<"Enter a number \n";
int n, x, f = 0;
cin>>n;
for(x=2; x<=n/2; x++) {
if(n%x==0) {
f=1;
break;
}
}
if (f==0){
cout<<n<<" is a prime number";
}
else{
cout<<n<<" is not a prime number";
}
return 0;
B)
Comments
Leave a comment