this is a program that display prime numbers from 1 to 100. it has problem linking when i run the program, someone please help. thx
#include <iostream>
class Prime
{ public:
int PrimeNo();
int Display();
};// class Prime number
int Prime::PrimeNo()
{ int i,j,count; //variable for counting loop
count=0;
for(i=1; i<101; i++) // i as the number to be determined
{
for(j=1; j< i%2; j++) //j as the divider
{ if(j%i==0)
count++;
}
}
if(count==2)
cout<<i;
else
cout<<'\n';
1) true is a reserved word. It should not even compile.
2) Your loos are wrong. They calculate how many divisors are there in first 100 numbers combined. Proper identation and usage of code tags would show it to you easily.