How to find and deal with maximum and minimum numbers?

Discussion in 'C Programming' started by zj262144, Oct 18, 2008.

  1. zj262144

    zj262144 Guest

    Hi, I'm a C beginner.
    I want to write a C.
    The pseudocodes are like this:

    User enters some numbers (use -1 to end)
    The compiler find and delete the maximum and minimum numbers
    Then average remained numbers
    Finally print the result

    Thanks in advance!!!
    zj262144, Oct 18, 2008
    1. Advertisements

  2. zj262144

    jacob navia Guest

    Do your own homework.

    Homework is there to TEACH you, if you do not do it yourself
    you will NOT learn anything
    jacob navia, Oct 18, 2008
    1. Advertisements

  3. Doesn't look like pseudocode to me, mor like a (homework) task. Maybe the
    following helps to get you started:

    read number
    max = min = sum = number

    read number
    if number > max
    max = number
    else if number < min
    min = number
    sum += number
    repeat while number not -1

    sum -= (min+max)
    counter -=2 /* to account for min amd max not being in anymore */
    result = sum/counter
    print result

    Bye, Jojo
    Joachim Schmitz, Oct 18, 2008
  4. I believe this to be wrong wording on the OP's part.

    Bye, Jojo
    Joachim Schmitz, Oct 18, 2008
  5. zj262144

    zj262144 Guest

    The homework just asks us to estimate the maximum from 10 integers.
    zj262144, Oct 18, 2008
  6. However: what you wrote isn't even an attempt to program something in C. Try
    it, if you get stuck post what code you have and there will be people
    helping you.

    Bye, Jojo
    Joachim Schmitz, Oct 18, 2008
  7. zj262144

    CBFalconer Guest

    This has nothing to do with the C language. First work out the
    algorithm (which is fairly simple). Then write the C code to
    implement the algorithm, which is even simpler.
    CBFalconer, Oct 19, 2008
  8. zj262144

    Bartc Guest

    Probably because dealing with an input stream consisting of numbers /or/
    words is more difficult than the original assignment.
    Bartc, Oct 19, 2008
  9. I don't think so. Testing for some special but otherwise valid
    number is more troublesome than reading numbers while there are
    numbers to read:

    while (scanf(...) == 1)
    /* do something with the number */;

    (details omitted because this is homework).
    Ben Bacarisse, Oct 19, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.