Ask Question
10 February, 23:38

What the output from the following code fragment:

int t1 = 87;

int t2 = 78;

int larger;

if (t1 > t2)

larger = t1;

else

larger = t2;

System. out. println ("larger: " + larger);

+5
Answers (1)
  1. 11 February, 01:40
    0
    The output will result to

    Nothing because there inst curly braces inserted so this code is continuously running.

    But if there was the output would result in Larger: 78 because your Sytem. out. prinln ("Larger: " + larger);

    Because it is located in the else statement

    If you want it to print out either way you would write it like so

    int t1 = 87; int t2 = 78; String larger = ""; if (t1 > t2) { larger = t1; }else{ larger = t2; } System. out. println ("Larger: " + larger);
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “What the output from the following code fragment: int t1 = 87; int t2 = 78; int larger; if (t1 > t2) larger = t1; else larger = t2; System. ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers