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
RSB [31]
3 years ago
7

What will be the values of ans, x, and y after the following statements are executed? int ans = 35, x = 50, y =50; if ( x >=

y) { ans = x + 10; x -=y; } else { ans = y + 10; y += x; } A. ans = 60, x = 50, y =100 B. ans = 60, x =0, y =50 C. ans = 45, x = 50, y = 0 D. ans = 45, x = 50, y = 50
Computers and Technology
2 answers:
Nutka1998 [239]3 years ago
6 0

Answer:

B. ans = 60; x = 0; y = 50

Explanation:

<em>(i)First format the code properly as follows:</em>

int ans = 35, x = 50, y =50;

if ( x >= y) {

ans = x + 10;

x -=y;

} else {

ans = y + 10;

y += x;

}

<em>(ii) Taking the if statement of the code;</em>

The if statement block is executed if x is greater than or equal to y (x >= y).

Since x=50 and y=50, then the code continues to execute the statement in the block.

In the if block;

(a) the first line is

<em>ans = x + 10. </em>

Since x = 50, substituting for x gives

ans = 50 + 10 = 60

Therefore <em>ans = 60</em>

(b) the second line is

<em>x -= y</em>

This can be re-written as

x = x - y.

This means that the value of x - y is written back into x. Therefore since x = 50 and y = 50, substituting for x and y gives

x = 50 - 50 = 0

Therefore <em>x = 0</em>

(c) the value of y is not changed at all, therefore <em>y = 50</em>

<em />

<em>(iii) Taking the else statement of the code;</em>

Since the if statement of the code has been executed, the else statement is simply skipped.

Therefore the final values of ans, x, y are respectively 60, 0 and 50

Hatshy [7]3 years ago
4 0

Answer:

B. ans = 60, x = 0, y = 50

Step wise Explanation of the code chunk

  • The first statement assigns value 35 to ans variable, value of 50 to x variable and value of 50 to y variable.
  • Next is an if statement which checks if the value of x variable is greater than or equal to y
  • This condition is true as x = 50 and y = 50 So x = y
  • Now since the statement is true it will enter the if block of the code which is the instruction: ans = x + 10; x -=y; and ignores the else block.
  • This line changes the value of ans variable and assigns it the value obtained by adding 10 to the value of variable x.
  • we know that         x = 50

        So

                                      ans = x + 10

                                      ans = 50 + 10

                                          ans = 60

  • After this, comes another line x -=y; which means decrement the value of x by value of y

that means:

                                              x = x - y

                                              x = 50-50

                                                  x = 0

  • So the new value of ans is 60, new value of x is 0 and the value of y remains the same i.e. 50

Hence

                                                ans = 60

                                                    x  =  0

                                                    y  = 50

                                     

You might be interested in
Question 4 of 10
Aleksandr [31]

Answer:

b

Explanation:

i dont really have one im just assuming bc of all the jobs my sibling have had

4 0
4 years ago
Which statement is LEAST accurate? Select one: a. A common reason for ERP failure is that the ERP does not support one or more i
Fittoniya [83]

Answer:

d. To take full advantage of the ERP process, re-engineering will need to occur.

Explanation:

Justification:  

ERP Implementation: ERP gives a change in technological ways for managing resources, the way to run the business is remained same but now Ft becomes well planned Diversified P units of Mich do not share common process. and data, generally employ phased-in approach of implementing ERP

• It is the way to overcome from the risk which is with the big bang approach, direct switching

• Perfect implementation of ERP needs re-engineering on the basis of performance

a. maintenance Sometimes ERP which is installed could not support one of the business process. due to lack of research before selecting it

• The statement that the diversified organizations. not. implement ERPs is least accurate because they implement it by employing phased-in approach Therefore, the correct option is d

3 0
4 years ago
You are installing an updated driver for a hardware device on your system. A dialog box displays indicating that Microsoft has d
inessss [21]

Answer:

It means the driver has been tested by Microsoft, and its an unaltered file.

Explanation:

A signed driver ensures that comes directly from Microsoft, it hasn't been modified by any other group or otherwise would lose the signature,  the driver is associated with a digital certificate that allows Windows to test its authenticity.

Since drivers work at very high-security levels on Windows OS, installing unsigned drivers it's a considerable risk.

7 0
3 years ago
Derek, a project manager, needs to create a plan for a software development project. Which approach or document will help him de
Lady_Fox [76]
For this one I would say C.) Work Breakdown Structure
6 0
3 years ago
Unscramble dki-----------------------------------------------------------------------...........
Fudgin [204]

Answer:

hmmmm.. kid?

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Members of which generation were born after the turn of the millennium?
    11·1 answer
  • Pick the JavaScript code for the following pseudocode. If age &gt;= 65 Then discountRate = 0.10 End If Group of answer choices
    12·1 answer
  • Programming assignment (100 pts): In the C++ programming language write a program capable of playing Tic-Tac-Toe against the use
    14·1 answer
  • Assume that two parallel arrays have been declared and initialized: healthOption an array of type char that contains letter code
    13·1 answer
  • Which of the following is not hardware? Question 7 options: A) Wireless network router B) Printer C) Virus Scanner D) Flat-panel
    11·1 answer
  • Climax Medical Technology, a fast-growing global research firm, has accumulated so much client information that conventional dat
    15·1 answer
  • Where are the worksheet tabs located
    7·1 answer
  • The measure of how quickly things may be converted to something of value is called.
    10·2 answers
  • Busco....................... Novio
    8·2 answers
  • Why would a programmer use the logical operator or in an if statement? (5 points)
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!