Ask 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. out. println ("larger: " + larger);

+1
Answers (1)
  1. 25 April, 14:22
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers