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
Maslowich
3 years ago
6

Consider the following code segment. int[][] arr = {{3, 2, 1}, {4, 3, 5}}; for (int row = 0; row < arr.length; row++) { for (

int col = 0; col < arr[row].length; col++) { if (col > 0) { if (arr[row][col] >= arr[row][col - 1]) { System.out.println("Condition one"); } } if (arr[row][col] % 2 == 0) { System.out.println("Condition two"); } } } As a result of executing the code segment, how many times are "Condition one" and "Condition two" printed?
Computers and Technology
1 answer:
ludmilkaskok [199]3 years ago
3 0

Answer:

Condition one - 1 time

Condition two - 2 times

Explanation:

Given

The above code segment

Required

Determine the number of times each print statement is executed

For condition one:

The if condition required to print the statement is:  <em>if (arr[row][col] >= arr[row][col - 1]) </em>

<em />

For the given data array, this condition is true only once, when

row = 1  and  col = 2

i.e.

<em>if(arr[row][col] >= arr[row][col - 1]) </em>

=> <em>arr[1][2] >= arr[1][2 - 1]</em>

=> <em>arr[1][2] >= arr[1][1]</em>

<em>=> 5 >= 3 ---- True</em>

<em />

The statement is false for other elements of the array

Hence, Condition one is printed once

<em />

<em />

For condition two:

The if condition required to print the statement is:  <em>if (arr[row][col] % 2 == 0) </em>

<em />

The condition checks if the array element is divisible by 2.

For the given data array, this condition is true only two times, when

row = 0  and  col = 1

row = 1  and  col = 0

i.e.

<em>if (arr[row][col] % 2 == 0) </em>

<em>When </em>row = 0  and  col = 1

<em>=>arr[0][1] % 2 == 0</em>

<em>=>2 % 2 == 0 --- True</em>

<em />

<em>When </em>row = 1  and  col = 0

<em>=>arr[1][0] % 2 == 0</em>

<em>=> 4 % 2 == 0 --- True</em>

<em />

<em />

The statement is false for other elements of the array

Hence, Condition two is printed twice

You might be interested in
A group of students writes their names and unique student ID numbers on sheets of paper. The sheets are then randomly placed in
kirill [66]

Answer:

D

Explanation:

For the linear search, the input range doesn't need to be sorted. It works on a both unsorted and sorted array.

For binary search, the input range must be sorted, otherwise, it will fail.

6 0
3 years ago
Aubrey didnt like to use graphics or images on her slides. She preferred to use only a title for her slides and bullet-poinged t
Fed [463]

Hiya!


<u>Answer:</u>

Of the options given, your answer is A.) As long as you use it responsibly, it will enhance your slides and engage your audience.

<u>Why is this correct?</u>

While Aubrey may not enjoy using media, a visual aid is sometimes needed outside of text. Even if it's sometimes a graphic or a chart, it does wonders to  help it make sense; especially with a mixed bag of people and I'd suggest you google it yourself as well. This means B is out. Sayonara!

Secondly, there MUST be a balance between media and text. Too many images will, as Aubrey believes, have an adverse effect on the presentation. So much as a caption on your photos is good. C is tonight's big loser.

Finally, there is the split between A and D. What do we do now? Both make some lick of sense, right? Think again. Media may help entertain your audience, but that's not the point of presentations most of the time; It's to present information in both a graphical/verbal format without using a video. In fact, I'd say it's harder for a presenter to describe a photo on his own, meaning it will NOT take pressure off the presenter.


I hope my answer helped!

8 0
3 years ago
Read 2 more answers
Upon connecting to a Wi-Fi network, you're redirected to a login screen and a request to accept terms of service before being co
kakasveta [241]

Answer:

captive portal

Explanation:

Captive portal -

It is a web page , which is opened along side the web browser which get displayed on to the fresh connected users of the Wi-Fi network , just before it gets the assurance to use the resources of the network , is known as captive portal .

Generally captive portal requires authentication or payment for access the internet resource .

Hence , from the question information , the example shown in the question is about captive portal .

4 0
3 years ago
manufacturers are making an effort to build energy-efficient computers and use recyclable cases and packaging true or false
Fittoniya [83]
True would be ur answer

Hope I helped:P
7 0
4 years ago
What do you understand by structured programmingapproach? Also Discuss about bottom up and top down approach.
mart [117]

Answer:

Structured programming also known as Modular programming in which the program is made as a single structure.The execution is instruction by instruction.It mainly focuses on improving the quality,clarity and development time of a computer program.

The top-down approach works by breaking a complex algorithm into smaller parts called modules. The modules keep breaking until there is no space left for breaking them without hindering the originality.The breaking of the modules is prohibited after achieving a certain level of modularity . C language uses this approach.

Bottom up works exactly opposite of how the top-down approach works.This approach works in the most elemental level of solving a problem and going up with combination of several parts of the solution to achieve required results.

4 0
3 years ago
Other questions:
  • Which of the following can be both an input device and an output device? mouse. keyboard. display screen. laser printer .
    9·1 answer
  • A technician is configuring a new SOHO multifunction wireless router at a customer’s location to provide network access to sever
    12·1 answer
  • Why should the drives be segregated in a computer?​
    15·1 answer
  • What do you mean by GIGO (Garbage-In-Garbage-Out) in computer system?​
    6·1 answer
  • Why is science, mathematics, and technology different from engineering?
    15·1 answer
  • Choose the tag required for each stated goal.
    12·1 answer
  • ¿Qué ayuda nos proporcionan las herramientas tecnológicas en estos tiempo de pandemia? ayudaaaaa plis
    9·1 answer
  • Difference between switch and switch lite
    10·1 answer
  • When would instant messaging be the least effective means of communication
    9·1 answer
  • When you start a new, blank document, you usually end up changing the font to arial 11. 5 point. How can you make these settings
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!