I can compile this program, but its kind of stuck, can anyone see whats wrong?
#include <iostream>
#include <cmath>
using namespace std;
main()
{
cout << "This program calculates the prime numbers between 0 and ";
int roof, numerator, denominator;
cin >> roof;
int score[roof]; //If the value 2 or 1 exist in one of the arrays, then the score[--number] is a prime number.
for (numerator = 1; numerator <= roof; numerator++)
{
denominator = 1;
for (denominator; denominator <= roof; denominator++)
{
if (numerator%denominator == 0)
{
score[numerator--]++;
}
}
}
cout << score[0] << endl;
cout << score[1] << endl;
cout << score[2] << endl;
cout << score[3] << endl;
cout << score[4] << endl;
}
Im trying to do this. If i make the roof to 6, then I just want to make these calculation.
% is modulus
!= no score
1%1 = score
1%2 !
1%3 !
1%4 !
1%5 !
1%6 !
2%1 = score
2%2 = score
2%3 !
2%4 !
2%5 !
2%6 !
3%1 !
and so on until 6%6
|