![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2008
Posts: 7
Rep Power: 0
![]() |
finding prime using bool
Hey I'm trying to figure out how to fix this program, i need to create and write a file Prime.txt and store prime numbers 1-100 using bool. right now I'm stuck and not sure whats wrong. All I'm getting is the black screen, and I'm not sure exactly where the file is then stored
c++ Syntax (Toggle Plain Text)
|
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 489
Rep Power: 4
![]() |
Re: finding prime using bool
line 12: replace ntc = 100 with ntc < 100
|
|
|
|
|
|
#3 |
|
Expert Programmer
|
Re: finding prime using bool
I believe that the file will be written to the directory in which the executable resides. If you are using an IDE which takes care of compilation for you, you may have to dig around to find it.
|
|
|
|
|
|
#4 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 489
Rep Power: 4
![]() |
Re: finding prime using bool
The problem was not the file but that infinite loop on line 12. The program never was able to write anything to the file.
|
|
|
|
|
|
#5 |
|
Expert Programmer
|
Re: finding prime using bool
My bad. I have had a problem in the past with not being able to locate the output of C++ programs that I wrote.
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,788
Rep Power: 5
![]() |
Re: finding prime using bool
Just as an aside, if you're generating a list of primes (as opposed to determining whether or not an arbitrary number is prime), the Sieve of Eratosthenes is a fairly intuitive and simple algorithm for doing just that. It's easy to implement, and might be a fun programming excercise for you. It's by no means necessary for the requirements of the program, but it will surely impress your teacher (if this is an assignment).
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| prime number, problem | cairo | C++ | 3 | Jun 2nd, 2006 1:43 PM |
| finding primes in an array | victor_shade | Java | 4 | Oct 27th, 2005 5:48 PM |
| Defining a bool type | nnxion | C | 6 | Oct 7th, 2005 8:39 AM |
| Prime Numbers | Konnor | C++ | 6 | Sep 12th, 2005 6:46 PM |
| Help with a couple prime numbers programs!! | BehemothPhoenix | C++ | 3 | Mar 20th, 2005 2:06 PM |