Ask Question
27 April, 19:55

What is output by the following C# code segment? int temp; temp = 180; while (temp! = 80) { if (temp > 90) { Console. Write ("This porridge is too hot! "); / / cool down temp = temp - (temp > 150? 100 : 20); } / / end if else { if (temp < 70) { Console. Write ("This porridge is too cold! "); / / warm up temp = temp + (temp < 50? 30 : 20); } / / end if } / / end else } / / end while if (temp = = 80) Console. WriteLine ("This porridge is just right!");

+5
Answers (1)
  1. 27 April, 22:37
    0
    Answer and Explanation:

    The output by the following C# code segment is (b) : This porridge is too hot! This porridge is just right!

    Explanation: first of all in this program declare a temp variable and assign a value 180 after that condition in the while-loop statement and if statement under while-loop will

    check first time it will true and console report showing result (This porridge is too hot!) and change the temp value from next line now temp value is set to 80 now first iteration of loop is completed and in next iteration, while loop condition is check now its condition is false so skip the loop and go to if state where check temp = 80 and print console value (This porridge is just right!)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What is output by the following C# code segment? int temp; temp = 180; while (temp! = 80) { if (temp > 90) { Console. Write ("This porridge ...” 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