Write a program that prompts the user to input a positive integer. It should then out

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ProgramingQUeen
    New Member
    • Dec 2017
    • 1

    Write a program that prompts the user to input a positive integer. It should then out

    Please help ive been stuck on this for a while and I'm just starting programming so I cant use anything past looping.
    Write a program that prompts the user to input a positive integer. It should then output a message
    indicating whether the number is a prime number or not. Solve this program using a flag
    controlled loop.
    For an added bonus if the number is not prime, you can display all the numbers it divides by.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    First question: What is a prime number? You can't write code unless you already know what the code is to do.

    Post your answer and we'll go from there.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      Which C type do you want to use to hold the “positive integer”? Refer to the description of limits.h for assistance.

      “Positive input” suggests that any number greater than zero is ok. As you study the definition of prime numbers you will see that the lower limit is actually greater than zero.

      Comment

      Working...