Skip to content

Commit c341556

Browse files
authored
Prime Check Code In C++ (thuva4#892)
1 parent c8eb224 commit c341556

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
using namespace std;
3+
// This Program Checks If A Number Is Prime Or Not And Returns An Output.
4+
// By Mr Techtroid
5+
int main() {
6+
int n;
7+
cout<<"Number:";
8+
cin>>n;
9+
int a = 0;
10+
for(int i=1;i<=(n/2);i++)
11+
{
12+
if(n%i==0 & i!=1)
13+
{
14+
break;
15+
}
16+
if (i == n/2){
17+
a = 1;
18+
}
19+
}
20+
if(a==1){cout << "Number is Prime" << endl;}
21+
else {cout << "Number Is NOT A Prime" << endl;}
22+
return 0;
23+
}

0 commit comments

Comments
 (0)