Question Details:I need help with this question in Microsoft Visual Studios 2008 C++ !!
1)
isPrime: A prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not a prime because it can be divied evenly by 1, 2, ,3 and 6.
Write a function name isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demostrate the functions in a complete program.
Tip: Recall that the % operator divides one number by another, and returns the remainder of the divison. In an ecpression such as num1% num2%, the % operator will return 0 if num1 is evenly divisible by num2.
So Far I have this, but there are syntex errors that i can not solve.
cpp
#include <iostream>
using namespace std;
bool isPrime(int prime)
{
cout << "Enter in an integer";
cin >> prime;
for (int counter = 2; counter < prime; counter++)
{
if(prime%counter == 0)
{
return false;
}
}
system ("pause");
return true;
}
MOD EDIT: Please
Thanks, gabehabe