Ask Question
7 June, 17:53

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

+3
Answers (1)
  1. 7 June, 21:27
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers