#include <iostream>
using namespace std;
bool isPrime (int num)
{
int counter=0;
{
for(int i=1; i<=num ; i++)
if (num%i==0) counter++;
if (counter==2)
return true;
}
return false;
}
//prints primes
void printPrimes (int num)
{
for(int i=2;i<=num;i++)
if (isPrime(i)) cout<<i<<",";
}
// if there is no prime number between 1 and num, getMaxPrime() should return a 0.
int getMaxPrime (int num)
{
?????????????????
}
// main function
int main()
{
int number;
do
{
cout << endl << endl
<< "Please enter a number, 0 or negative to stop: ";
cin >> number;
if (number > 0)
{
cout << "All the prime numbers between 1 and "<< number <<" are: "<< endl;
printPrimes(number);
cout << "\nThe max prime is: ";
int maxPrime = getMaxPrime(number);
if (maxPrime == 0) cout << "none.";
else cout << maxPrime;
}
}
while (number>0);
return 0;
}
i just found this site so i dono how to add numbers to the each line and make it look nice but is there anyone who can give me like step by step description of whats happening here?? i just need to study for the final that is coming up because prof. said there will be question on prime number