Thread: n00b Question- Loops

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    1

    n00b Question- Loops

    How would I go about doing this:

    Write a program that asks the user to enter a number between 1 - 5. Your program should display all the numbers between 1-20 that are evenly divisible by this number. You will need to use a loop.

    Thanks,

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    We're not going to do your homework for you - please post the code that you have, and any specific questions, and we can point you in the right direction.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    A simple (infinite) loop would be...
    Oh and the inside is a loop as well - from 1 to 20.
    Code:
    while (1) {
        /* ask for user input */
        for (i = 1; i <=20; i++) {
            /* display the number i if it's divisible by the user's number */
            }
        }

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    What you should do first is write a flowchart. Reply after you've done that.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question concerning for loops
    By Programmer_P in forum C++ Programming
    Replies: 36
    Last Post: 05-26-2009, 05:11 PM
  2. Question about loops
    By lroberts1016 in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2008, 07:01 PM
  3. noob question re: switch case & loops
    By scooglygoogly in forum C++ Programming
    Replies: 13
    Last Post: 08-25-2008, 11:08 AM
  4. question on GCD and for loops
    By dals2002 in forum C Programming
    Replies: 9
    Last Post: 03-15-2008, 01:59 AM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM