Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Four int variables, x1, x2, y1, and y2, have been declared and been given values

ID: 3651263 • Letter: F

Question

Four int variables, x1, x2, y1, and y2, have been declared and been given values. Write an expression whose value is the difference between the larger of x1 and x2 and the smaller of y1 and y2.

Explanation / Answer

int x1,x2,y1,y2,ans=0; ans = (((x1>x2)?x1:x2)-((y1>y2)?y2:y1))) the first poster was correct but this needs some explanation i think. The "?" operator is like its own if statement. So((x1>x2)?x1:x2) is like saying: if(x1> x2) avariable = x1 else avariable = x2 If you are using C/C++ (and I think Java)this will work fine but if you are using VB you'll need the if statements like I just demonstrated

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote