Ok, so now I am on part 2 of my homework and I believe I need to use an array in order to solve the second part. But, we have yet to cover arrays in class and I am unsure on how to accomplish this. Ive put in some aspects of an array but Im not sure if I did it right.
#include<iostream>
usingnamespace std;
int main()
{
int x, y,z, count = -1;
int *array = newint[0];
bool prime = true;
cout << "What is the total number of prime numbers?!.\n";
cout << "Please enter a number.\n";
cin >> x;
for (z = 2; z <= x - 1;z++)
{
bool prime = true;
for (y = 3; y <= z-1; y++)
{
if (z%y == 0)
{
prime = false;
break;
}
}
if (prime) count++;
}
for (z = 2; z <= x - 1; z++)
{
bool prime = true;
int *array = newint[x];
for (y = 3; y <= z - 1; y++)
{
if (z%y == 0)
{
prime = false;
break;
}
}
if (prime)
{
(z + 1);
(z % 2 == 0);
cout << "The highest Mersenne Prime is\n" << z << endl;
}
}
cout << "The total number of prime numbers less than\n" << x << " "<< "is" <<" "<< count<< endl;
delete[] array;
return 0;
}
I get the right number of Mersenne Primes but I need it to only print out the highest one.