1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ksivusya [100]
3 years ago
8

What is output by the following C# code segment? int temp; temp = 180; while ( temp != 80 ) { if ( temp > 90 ) { Console.Writ

e( "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!" );
Computers and Technology
2 answers:
tekilochka [14]3 years ago
3 0

Answer:

The output of the code is

This porridge is too hot!

This porridge is just right

Explanation:

First, I'll need to arrange the code properly

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

At line 2, the value of temp is 180

At line 3, an iterative statement is used to test if temp is not Equal to 80.

The statement is true so the code within the iteration is performed

At line 4, the values of temp is tested again

Is temp greater than 70?

Yes

At this point, the compiler prints "This porridge is too hot! " , Without the quotes

The next line performs arithmetic and assignment operation on temp

First, is temp greater than 150?

Yes

So, the arithmetic operations becomes

temp = 180 - 100 which gives 80

All other statements within the while iteration are then ignored

The compiler then test for the second time if temp is still not equal to 80.

Note that at this point, temp = 80

So, the test is false

All statements within the while iteration will then be ignored.

Program execution then moves to line 14.

Is temp = 80?

Yes

The compiler prints "This porridge is just right!" without the quotes.

Salsk061 [2.6K]3 years ago
3 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!)

You might be interested in
A. Convert decimal 37 to binary
lisabon 2012 [21]

Answer:

100101

25

5E7

101000011100

Explanation:

4 0
3 years ago
You are the administrator for the contoso.com website. recently, the server hosting the website had a failure that caused it to
Alisiya [41]
Protecting the Power supply
Adding disk Arrays
Install an NLB Cluster
4 0
3 years ago
Which is true about a computerized spreadsheet?
morpeh [17]
"A computerized spreadsheet automatically recalculates when changes are made to the data" is the one among the following that <span>is true about a computerized spreadsheet. The correct option among all the options that are given in the question is the third option or option "C". I hope it helps you.</span>
5 0
3 years ago
To avoid legal issues and set clear guidelines and expectations for employees, employers should put which of the following in pl
Mademuasel [1]

Answer: social media policy

Explanation:

In order to avoid legal issues and also set clear guidelines and expectations for the employees in an organization, it is required that employers should put a social media policy in place.

A social media policy refers to a document which outlines how an organization and the employees will behave and conduct themselves online. This helps to checkmate and curtail the activities of the employees so that there won't be a detrimental effect on the organization.

8 0
2 years ago
Describe the object-oriented software engineering approach.
Jobisdone [24]

Answer:

 The object oriented software engineering approach is basically focus on the attention for capture the given structure and conduct the data frameworks in the form of small module which consolidates the information and the procedure.

The principle and aim of the Object Oriented Design (OOD) is that improving the quality of the system analysis and increase its productivity and more usable efficiently.

There are different phases in the object oriented software engineering approach are as follows:

  • Firstly, we start analyze and define the particular system
  • Then, construct the analysis model based on the above approach of the specific system.
  • We verify the correctness of the system by using the testing.

3 0
3 years ago
Other questions:
  • Concept of CPU scheduler?​
    7·1 answer
  • Write a program that lets a maker of chips and salsa keep track of their sales for five different types of salsa they produce: mi
    8·1 answer
  • Maxwell says three things Level Two Leaders do well are:
    6·1 answer
  • Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. When she reads over the pag
    10·1 answer
  • Drag each label to the correct location on the image.
    10·1 answer
  • What HTML tag would you use to indicate a line break?
    5·1 answer
  • . Let F(X, Y, Z)=(X + Y + Z)(X + Y + Z)(X + Y + Z)(X + Y + Z). Use a 3-variable K-Map to find the minimized SOP form of this fun
    15·1 answer
  • In ________ for final fields and methods the value is assignedlater but in ______ you assign the value during declaration.
    15·1 answer
  • You are creating a presentation and you have come to the last slide. You still have more information to add. What should you do?
    7·1 answer
  • In terms of technology, wich of the four devices is the most recent?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!