help with array that determines prime numbers

Reply

Join Date: Feb 2005
Posts: 10
Reputation: notdumb is an unknown quantity at this point 
Solved Threads: 0
notdumb notdumb is offline Offline
Newbie Poster

help with array that determines prime numbers

 
0
  #1
Feb 21st, 2005
Hi,

My assignment for class was to produce a program that runs the seive of eratosthenes to determine all the prime numbers between 2 and n, with n no larger than 100. I tryed to write the program with a boolian array that will turn all non-primes to false up to the max of 100, and then only output to the requested input of n.

Quite honestly, this confuses me and I am not even sure I have the process right, let alone the program. As is, I am getting an unresolved external error upon linking. Line 38 is what I am most unsure of, and for some reason think my error is there.

Any advice or help on getting this thing running would be much appriciated. How am I doing?

Thanks.--Will
Attached Files
File Type: cpp ethernes.cpp (825 Bytes, 38 views)
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 10
Reputation: notdumb is an unknown quantity at this point 
Solved Threads: 0
notdumb notdumb is offline Offline
Newbie Poster

Re: help with array that determines prime numbers

 
0
  #2
Feb 21st, 2005
OK, I got a bit further and think I have the basic idea down, however, I am still getting the unresolved externals message. Attatched is my improved code. Thanks. Will


Originally Posted by notdumb
Hi,

My assignment for class was to produce a program that runs the seive of eratosthenes to determine all the prime numbers between 2 and n, with n no larger than 100. I tryed to write the program with a boolian array that will turn all non-primes to false up to the max of 100, and then only output to the requested input of n.

Quite honestly, this confuses me and I am not even sure I have the process right, let alone the program. As is, I am getting an unresolved external error upon linking. Line 38 is what I am most unsure of, and for some reason think my error is there.

Any advice or help on getting this thing running would be much appriciated. How am I doing?

Thanks.--Will
Attached Files
File Type: cpp ethernes.cpp (837 Bytes, 56 views)
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 45
Reputation: Siersan is an unknown quantity at this point 
Solved Threads: 2
Siersan's Avatar
Siersan Siersan is offline Offline
Speaker of Truth

Re: help with array that determines prime numbers

 
0
  #3
Feb 21st, 2005
What errors you are getting? It compiles and runs just fine for me except every prime is 1 larger than it should be because you add 1 to m when printing.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC