Totally Stumped On This Total Noob Problem

Alright so I need to find the largest of three numbers using a single condition test in each if statement. I can have nested if statements, but I'm not allowed to use compound conditions (that is part two of the assignment which I have already completed). Below is the code I have for the second part just so you can get a feel of what my code needs to look like to meet the professor's standards. I'm completely stumped on this problem.

1
2
3
4
5
6
7
8
if ((firstNumber > secondNumber) && (firstNumber > thirdNumber))
   txtLargest->Text = firstNumber.ToString();
else
   if ((secondNumber > firstNumber) && (secondNumber > thirdNumber))
      txtLargest->Text = secondNumber.ToString();
   else
      if ((thirdNumber > firstNumber) && thirdNumber > secondNumber))
	  txtLargest->Text = thirdNumber.ToString();
closed account (ypLhURfi)

if ((firstNumber > secondNumber) && (firstNumber > thirdNumber))
txtLargest->Text = firstNumber.ToString();
else
if ((secondNumber > firstNumber) && (secondNumber > thirdNumber))
txtLargest->Text = secondNumber.ToString();
else
if ((thirdNumber > firstNumber) && (thirdNumber > secondNumber))
txtLargest->Text = thirdNumber.ToString();
Last edited on
IF (secondNumber < firstNumber)
THEN firstnumber or thirdnumber is the largest
ELSE secondnumber or thirdnumber is the largest

In other words each of the two branches has two candidates to test.


Oh, wait, what if you have equal numbers?
Thanks so much for the response.
Topic archived. No new replies allowed.