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
Rectangle perimeter is 72 .Find the new perimeter if length is doubled and breadth is tripled​
777dan777 [17]

Answer:

Is it related to technology and computers?

3 0
2 years ago
In javascript, what can I put after player. to make my character go in the center of the screen? like example:
melamori03 [73]

Answer:

0,0

Explanation:

you could try to use the x-axis and y-axis to put your character in a certain place. I'm not totally sure if that is how javascript works, but for the x-axis and y-axis, the center is always(0,0).

6 0
3 years ago
Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, the program outputs the strings fro
Lesechka [4]

Answer:

See explaination for the code

Explanation:

def wordsOfFrequency(words, freq):

d = {}

res = []

for i in range(len(words)):

if(words[i].lower() in d):

d[words[i].lower()] = d[words[i].lower()] + 1

else:

d[words[i].lower()] = 1

for word in words:

if d[word.lower()]==freq:

res.append(word)

return res

Note:

First a dictionary is created to keep the count of the lowercase form of each word.

Then, using another for loop, each word count is matched with the freq, if it matches, the word is appended to the result list res.

Finally the res list is appended.

3 0
3 years ago
Technician A says that oil for the rod bearings comes from splash off the crankshaft. Technician B says that lubrication to the
worty [1.4K]

Answer: technician B

Explanation:

The oil is picked up from the oil pump though a pick up tube that is mounted on the oil pump. The end of the pick up tube sits in the oil at the bottom of the oil pan. The oil is then forced through holes that are drilled into the block. Those holes which are called (journals) lead to the main bearings,rod bearings,lifters, camshaft, ect..

7 0
3 years ago
Which of the following detects unauthorized user activities, attacks, and network compromises, alerts of the detected attacks, a
Anit [1.1K]

The answer is IPS (Intrusion Prevention Systems)

The Intrusion Prevention Systems and Intrusion Detection Systems (IDS) are two security technologies that secure networks and are very similar in how they work. The IDS detects unauthorized user activities, attacks, and network compromises, and also alerts. The IPS, on the other hand, as mentioned, is very similar to the IDS, except that in addition to detecting and alerting, it can also takes action to prevent breaches.


3 0
3 years ago
Other questions:
  • 3. Megan and her brother Marco have a side business where they shop at flea markets, garage sales, and estate
    9·1 answer
  • I am confused about joins in sql.
    8·2 answers
  • What is daemontools pakage in qmail?
    14·1 answer
  • There are no breakpoints in the "Access Customer Account" subpage however there is an error. What will happen if you choose to s
    11·1 answer
  • Because it takes time to change an organization’s culture, the ISO must continually monitor security policy compliance. The ISO
    9·1 answer
  • Yall like portal 1 or 2
    8·1 answer
  • Explain how to utilize the computer in rooms management.​
    13·1 answer
  • Can anyone help me this is due today :) <br> Thank you so much
    14·2 answers
  • Select the correct answer.
    11·1 answer
  • the term elastic in ec2 refers to the fact that you can easily increase or decrease the number of servers you run to support an
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!