Thread: display numbers in order

  1. #1
    Registered User mike's Avatar
    Join Date
    Aug 2001

    display numbers in order

    Hi I am working on a program that is supposed to have the user enter three number between -5 and +5. then the program puts the numbers in order by least to greatest order. here is what i have so far. thanks for any help!

    #include "stdafx.h"
    #include <iostream.h>

    int a;
    int b;
    int c;

    int main(int argc, char* argv[])

    cout<<"Enter in Three Numbers between -5 and +5\n";

    if(a < -5 || a >= +6)

    cout<<"Numbers do not fall within range\n";

    return 0;


    if(b < -5 || b >= +6)

    cout<<"Numbers do not fall within range\n";
    return 0;


    if(c < -5 || c >= +6)
    cout<<"Numbers do not fall within range\n";
    return 0;


    if(a<b && a<c)

    if(b>a && b<c)

    if(c>a && c>b)

    if(b<a && b<c)

    if(c>a && c<b)

    if(a>b && a>c)


    return 0;

  2. #2
    Registered User
    Join Date
    Sep 2001
    Try something like this to get your data

    int nNumber[3] ={0}
    for(int i = 0; i < 3;i++)
    place the input in nNumber array and check each input for ranges

    Now call a function that takes a pointer to an int and call it with nNumber. Look around for some information on a bubble sort. Use that on your array in this function.

    Upon return from the previous function iterate the array printing out the numbers in order. Sorta like what you did to get the data into the array.

    Let me know if you have any questions.

  3. #3
    yeah dude defently use an array it will be much easier...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do you order your game code?
    By Queatrix in forum A Brief History of
    Replies: 15
    Last Post: 02-05-2006, 06:26 PM
  2. Adding Line numbers in Word
    By Mister C in forum A Brief History of
    Replies: 24
    Last Post: 06-24-2004, 08:45 PM
  3. Array's Help
    By bmx4christ in forum C Programming
    Replies: 15
    Last Post: 12-08-2003, 12:40 PM
  4. Sorting numbers in descending order
    By Yunasnk in forum C++ Programming
    Replies: 2
    Last Post: 11-23-2003, 05:55 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM