hi every body
this is my first post in this wonderfull web site
i'm a biggener in c++ and i have a q
i want to do a function that determines whether a number is prime and then use this function in a program that prints all the prime numbers between 1 and 10000
this is what i done and the result is wrong ... i don't know why
#include<iostream>
using namespace std;
int z;
bool prime(int x)
{
for(int i=2;i<x,i>x;i++)
{
z=x%i;
if(z==0)
return false;
break;
}
while (z)
return true;
}
int main()
{
int k=0;
for(int i=0;i<=10000/2;i++)
{
bool y=prime(i);
if(i)
cout<<i<<" is prime"<<endl;
else
cout<<i<<" is not prime "<<endl;
}
return 0;
}
what do u think ?