Implement in C ++, using a personal library, an application that determines based on the choice made by the user if a number is positive or negative or if a number is prime or not. This is the main code:
#include <iostream>
#include "libreria.cpp"
using namespace std;
int s;
int main()
{
int num1,cont;
cout<<"\n 1) Positive ";
cout<<"\n 2) Prime ";
cout<<"\n 3) Exit ";
cout<<"\n Choose: ";
do
{
cin>>s;
switch (s)
{
case 1:
cout<<"\nInsert the number: ";
cin>>num1;
bool sepos(int numb);
if (bool sepos(int numb)==1)
{
cout<<"\nIl numero "<<num1<<" e' positive";
}
else
{
cout<<"\nIl numero "<<num1<<" e' negative";
}
break;
case 2:
break;
}
} while (s!=3);
return 0;
}
The library is:
bool sepos(int numb)
{
if(numb>=0)
{
return true;
}
else
{
return false;
}
}
For now, I was trying to see if the number was positive or not. But the application won't work, i got a lot of errors.
[Error] function 'bool sepos(int)' is initialized like a variable
[Error] expected primary-expression before '==' token
[Error] expected '=' before '==' token
[Warning] declaration of 'bool sepos(int)' has 'extern' and is initialized