I have been trying VERY hard on this one and I cannot figure it out (I get the logic-- but not how to apply it in a COMPUTER).
Here it is (please read the whole thing before answering):
This is C programming (not C++)
I need to design a program that will find the highest and lowest number of any 4 integers.
1) It has to be a cascade of "if" and "else"
2) I can only use a total of 4 "if"s (elses are not limited)
3) It has to be very very basic (this is only the 2nd week of class)
What I did-- which worked with LOGIC-- was this:
If ((A>B && A>C && A>D) || (A<B && A<C && A<D))
MAXMIN1 = A
.... and so on, in a process of elimination. (where I ran into trouble was with the number of "if"s. I was only able to get down to 5, using this method).
(beginning with a comparison of A to B and C to D didn't work because it required that the max be in the AB group and the min be in the CD group, or vice versa (you couldn't have max AND min in the AB group)--- remember, I am only allowed 4 "if"s.
Anyone have a solution? I have been working for 2 days and cannot get it. I tried my best. But part of life is knowing when to ask for help (and the teacher is cool, but he won't help)........
I would be grateful : )
Edited by cocopium: more info