By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

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

P: 1
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.
Dec 21 '17 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
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.
Dec 21 '17 #2

Expert 100+
P: 2,396
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.
Dec 22 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.