# include <cmath> // This library enable the use of sqrt.
# include <iostream>
usingnamespace std;
void primenum(longdouble); // Prototype...
int c = 0;
int main()
{
longdouble x = 0;
cout<<"\n This program will generate all prime numbers up to the"
<<"\n number you have entered below...\n";
cout<<"\n Please enter a number: ";
cin>> x;
cout<<"\n Here are all the prime numbers up to "<<x<<".\n";
primenum(x); //function invocation...
cout<<endl<<"\nThere are "<<c
<<" prime numbers less than or equal to "<<x<<".\n\n";
return 0;
}
// This function will determine the primenumbers up to num.
void primenum(longdouble x)
{
bool prime = true; // Calculates the square-root of 'x'
int number2;
number2 =(int) floor (sqrt (x));
for (int i = 1; i <= x; i++){
for ( int j = 2; j <= number2; j++){
if ( i!=j && i % j == 0 ){
prime = false;
break;
}
}
if (prime){
cout <<" "<<i<<" ";
c += 1;
}
prime = true;
}
}
#include <iostream>
int main()
{
int freq=0;
for(int i=1;i<100;i++){
int isZero=0;
for (int j=1;j<i;j++)
{
if (i%j==0)
isZero++;
}
if (isZero ==1)
{
freq++;
}
}
std::cout << "The Frequecy of Prime Number is " << freq << std::endl;
return 0;
}