Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- void prime_numbers_check(int a){
- int counter = 0;
- for(int i = 2; i <= (int)sqrt(a); i ++)
- if(a % i == 0) counter ++;
- if(counter > 0) cout << a << " is a composite number" << endl;
- else cout << a << " is a prime number" << endl;
- }
- int main()
- {
- int a;
- bool flag = 1;
- while (flag){
- cout << "Enter integer number" << endl;
- cin >> a;
- prime_numbers_check(a);
- cout << "Press: 1 - continue, 0 - finish ";
- cin >> flag;
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement