473,471 Members | 2,613 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

1 New Member
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
2 3148
weaknessforcats
9,208 Recognized Expert Moderator Expert
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
donbock
2,426 Recognized Expert Top Contributor
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

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

Similar topics

4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
1
by: haelly | last post by:
write a program that prompts the user to enter three different positive integer values.If the values are not different, the program prints a message"equal value" and terminates(hint:use the return...
4
by: Tarique | last post by:
Hello All. Is the following good enough to be a safe user input routine? What else should i do to improve it ? #include<stdio.h> #include<stdlib.h> #include<string.h> #define ARRAYSIZE 100 ...
2
by: janue | last post by:
Hi all, I am trying to display a menu of choices in my c program, and my program will return an error if user do not enter the right integer or entered a non-integer input. I tried: ...
1
by: Aphex | last post by:
I want to get user input of integer value only and store it in a int. Then I want to take that int and make it a square root. How would I get User Input?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.