Thread: C range sentinels loop.

  1. #1
    Registered User
    Join Date
    Oct 2016
    Posts
    1

    C range sentinels loop.

    I really need help with this question. Please explain? Also answer.

    Given an int variable n that has already been declared , write some code that repeatedly reads a value into n until at last a number between 1 and 10 (inclusive) has been entered.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    It is kind of difficult to help you without giving the code away when the instructions are so clear and specific. But okay, let's review what you should already know:
    • Write a program that declares an int variable named n and reads a value into it.
    • Write another program that uses a while loop in some reasonable way, e.g., to loop from 0 to some integer greater than 0, printing the number on each iteration of the loop. (This particular pattern of logic would normally be done with a for loop, but for practice use a while loop.)

    Can you write the two programs outlined above? If not, what problems are you facing?

    If you can write the two programs outlined above, show your code. From there we can guide you to incorporate the two concepts into one program that does what your original question is asking you to do.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 03-04-2013, 03:00 PM
  2. range?
    By tu_user in forum C++ Programming
    Replies: 13
    Last Post: 01-19-2004, 11:35 PM
  3. Range
    By volk in forum C Programming
    Replies: 3
    Last Post: 12-19-2002, 09:43 AM
  4. Range
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 05-23-2002, 10:52 AM
  5. SRAND in a range
    By Robert_Ingleby in forum C++ Programming
    Replies: 3
    Last Post: 11-22-2001, 07:53 AM

Tags for this Thread