Thread: need to find smallest int

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    2

    need to find smallest int

    hi
    i need to make a program that uses a "while loop" to find the smallest of user defined integers
    can anyone give me a hint?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What you mean by "smallest of user defined integers"? As in you have say, an array of integers from user input, and you want to find the minimum element in this array?
    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

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    declare a variable min and initialize with first int
    compare min with every int. if an int is less than min, then assign min to that int
    when you have finished all the int, min should be the minimum

    the values can be stored in an array and use a while loop with an index

  4. #4
    Registered User
    Join Date
    Nov 2008
    Posts
    2
    thank u

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. NEED HELP READING FILE and PRINTING
    By geoffr0 in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 05:26 PM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  4. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM