-
Notifications
You must be signed in to change notification settings - Fork 7
/
29_Prime_Constructor.cpp
41 lines (32 loc) · 1.1 KB
/
29_Prime_Constructor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*Write a CPP program to print a number is prime number or not
Sample Input-Output:
Enter the Number:7
7 is Prime Number.
Enter the Number:6
6 is Not Prime Numbers.
*/
#include<iostream>
using namespace std;
class Number{
int num;
public:
Number(){
cout << "Enter the Number:";
cin >> num;
int flag = 0;
for(int i = 2; i<num; i++){
if(num%i == 0){
cout << num << " is Not Prime Numbers.";
flag = 1;
break;
}
}
if(flag == 0){
cout << num << " is Prime Number.";
}
}
};
int main(){
Number n;
return 0;
}