Search:

Submit Article

# Program to find the total no of prime numbers between 1 to n by using thread

Posted By: Easy Tutor     Category: C Programming     Views: 8488

## Code for Program to find the total no of prime numbers between 1 to n by using thread in C Programming

```# include <stdio.h>

int TotalCount=0;
int iNumber;

int main()
{
int iCount,jCount;
int PrimeFlag=1;
printf("Enter Number Up to Which You want to Count Prime Numbers :");
scanf("%d",&iNumber);
for(iCount=2;iCount<=iNumber/2;iCount=iCount++)
{
for(jCount=2;jCount<iCount;jCount++)
{
if(iCount%jCount==0)
{
PrimeFlag=0;
break;
}
}

if(PrimeFlag==1)
{
printf("[ %d ]  Main\n",iCount);
TotalCount=TotalCount++;
}
else
{
PrimeFlag=1;
}
}

printf("Final Count is : %d \n",TotalCount);
return 0;
}

{
int *ifrom,iCount,jCount;
int PrimeFlag=1;
ifrom=(int*)no;

for(iCount=*ifrom;iCount<=iNumber;iCount=iCount++)
{
for(jCount=2;jCount<iCount;jCount++)
{
if(iCount%jCount==0)
{
PrimeFlag=0;
break;
}
}

if(PrimeFlag==1)
{
TotalCount++;
}
PrimeFlag=1;
}
}
```
Share:

 Easy Tutor author of Program to find the total no of prime numbers between 1 to n by using thread is from United States. Easy Tutor says Hello Friends,I am Free Lance Tutor, who helped student in completing their homework. I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] comI have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada. I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.Thanks,Happy Programming :) View All Articles

• Comment should be atleast 30 Characters.