Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
Create C program that calculates prime numbers from a certain number X to a number Y. Modify the program so as to run two threads at the same time. The first thread will start counting from X to Y and the second from Y to Z
Posted
Updated 26-Jan-13 6:50am
v2

This looks like homework.

It would be best if you did your own homework. It is given to you so that you will learn something, think about what have been taught. Read your text books and give it a try.

Some resources to help you:
Prime number[^]
C multi-threading search[^]

Once you have code and run into problems you can always come back here with a more specific question and the community will do its best to help you. Don't forget to post only the relevant code bits that pose the problem as a code dump is not usually helpful at all in getting someone to help/assist you.

Good luck and happy coding.
 
Share this answer
 
That sounds like a bad homework assignment.
Look into Sieve of Eratosthenes. I don't think it lends itself to multi-threading though.
 
Share this answer
 
The example code at this[^] article does a multi-threaded sieve of Eratosthenes using the actor programming model. It is C++ though (not C). By changing the number of primes handled by each thread, you can control the number of threads (ie. restrict to 2).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900