I need to write c program which would count total numbers of prime between 0 & input value. I cannot use scanf so I must write main function. using command line argument..
Please Please Help Me
C Program that counts total prime number
Started by exe101, Apr 06 2009 05:39 PM
3 replies to this topic
#1
Posted 06 April 2009 - 05:39 PM
|
|
|
#2
Posted 06 April 2009 - 06:35 PM
Isnt this cheating?
#3
Posted 06 April 2009 - 10:15 PM
I don't think it's quite right for us to code your entire assignment for you...
But you'll find it much easier if you map it out with some sort of pseudocode first. Just sentence-by-sentence, in plain English, describe what your program needs to do. Something like this:
Receive input from user.
Check if input is valid.
Check if number is prime (have to determine algorithm - the core of the assignment)
Check if number-1 is prime...number-2... and so on until you reach 1.
If/when a prime number is detected, increment a counter by one.
Display results.
The algorithm would be the hard part. You have to ask yourself how you would determine whether a number was prime, using pencil and paper. What techniques would you use? What would your process be? Then write a function that does that process.
But you'll find it much easier if you map it out with some sort of pseudocode first. Just sentence-by-sentence, in plain English, describe what your program needs to do. Something like this:
Receive input from user.
Check if input is valid.
Check if number is prime (have to determine algorithm - the core of the assignment)
Check if number-1 is prime...number-2... and so on until you reach 1.
If/when a prime number is detected, increment a counter by one.
Display results.
The algorithm would be the hard part. You have to ask yourself how you would determine whether a number was prime, using pencil and paper. What techniques would you use? What would your process be? Then write a function that does that process.
#4
Posted 07 April 2009 - 07:19 AM
What do you have so far?


Sign In
Create Account

Back to top









