← Back to Forum

print all prime numbers

Posted on November 30, 2024, 2:08 pm


#include<stdio.h>
int main()
{
int num;
int i;
int flag=0;
int count=1;

for(num=3;num<100000;num++)
{
flag=0;
for(i=2;i<sqrt(num);i++)
{
if(num%i==0)
{
flag=1;
count++;
break;
}
}


}
printf("\n The total prime numbers are %d",count);

return 0;
}


Add a Reply


Replies (0)

No replies yet. Be the first to reply!