How to find and deal with maximum and minimum numbers?

Z

zj262144

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!!!
 
J

jacob navia

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!!!

Do your own homework.

Homework is there to TEACH you, if you do not do it yourself
you will NOT learn anything
 
J

Joachim Schmitz

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!!!

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

read number
counter=1
max = min = sum = number

loop
read number
counter++
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
 
J

Joachim Schmitz

Richard said:
Joachim Schmitz said:


Sorry, but I don't think that answers the OP's question. He wants the
*compiler* to find and delete the maximum and minimum numbers.

I believe this to be wrong wording on the OP's part.

Bye, Jojo
 
Z

zj262144

(e-mail address removed) wrote:

Do your own homework.

Homework is there to TEACH you, if you do not do it yourself
you will NOT learn anything

NO
THIS ISN'T HOMEWORK!
The homework just asks us to estimate the maximum from 10 integers.
 
J

Joachim Schmitz

NO
THIS ISN'T HOMEWORK!
The homework just asks us to estimate the maximum from 10 integers.

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
 
C

CBFalconer

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

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.
 
B

Bartc

William Pursell said:
Why not use EOF or something that isn't a number
(for example, 'q') to terminate input?

Probably because dealing with an input stream consisting of numbers /or/
words is more difficult than the original assignment.
 
B

Ben Bacarisse

Bartc said:
Probably because dealing with an input stream consisting of numbers
/or/ words is more difficult than the original assignment.

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).
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top