Ask Question
2 October, 01:06

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

+1
Answers (1)
  1. 2 October, 02:34
    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?
Get 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 & 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