for loop to find prime numbers

This is a discussion on for loop to find prime numbers within the C Programming forums, part of the General Programming Boards category; Hello everyone! I'm truly in a squeeze that I dyerly need help on! I need a program that prints the ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    1
    Hello everyone! I'm truly in a squeeze that I dyerly need help on!

    I need a program that prints the prime numbers that are there between two given positve integers(The first integer is less than the second.). In other words, the program should accept two positive integers from the keyboard(i.e. from user during runtime.) as input and display all prime numbers(in an order) between these two integers.
    Ex. If the input is 3 and 13 then the program should display 5, 7, 11

    Can sombody please help???

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,344
    Split from for loop to find prime numbers
    Next time, read the board rules.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    for ever odd from low to high
        test for prime
    You do the rest.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Prime numbers
    By Imbellis in forum C Programming
    Replies: 25
    Last Post: 11-27-2008, 05:37 AM
  2. Logical errors with seach function
    By Taka in forum C Programming
    Replies: 4
    Last Post: 09-18-2006, 05:20 AM
  3. prime numbers re-posted
    By crypto_quixote in forum C Programming
    Replies: 3
    Last Post: 01-17-2006, 07:44 PM
  4. printing only prime numbers
    By Micko in forum C Programming
    Replies: 30
    Last Post: 06-10-2004, 10:23 PM
  5. Prime Numbers
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 09-24-2001, 07:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21