Мне нужно сделать программу, которая передает номер пользователя функции bool, которая вернет ответ bool
, если число является простым числом или нет, а затем программа если число простое или нет. Это то, что у меня есть, и я полностью застрял.Я пытаюсь написать первую программу # в C++
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
//Declare return function
bool isPrime(int);
//Declare constant
const int PRIME=2;
int main()
{
//Declare local variable to store user number
int user_num;
//Declare local variable to store result
bool result;
//Declare variable to hold return
bool status;
//Request number from user
cout << "Please enter a number" << endl;
cin >> user_num;
//Call function isPrime
bool isPrime(int user_num);
if (status==true)
cout << user_num << "is prime" << endl;
else
cout << user_num << "is not prime" << endl;
system ("PAUSE");
return 0;
} //end main
//Define bool function
bool isPrime(int number)
{
bool status;
double num_1=sqrt(number);
for (int i=2;i<=num_1;++i)
if(!(number%i))
status=false;
else
status=true;
return status;
}//End bool function