Consider the following code segment, where num is an integer variable.

int [][] arr = {{11, 13, 14 ,15},
{12, 18, 17, 26},
{13, 21, 26, 29},
{14, 17, 22, 28}};
for (int j = 0; j < arr.length; j++)
{
for (int k = 0; k < arr[0].length; k++)
{ if (arr[j][k] == num){System.out.print(j + k + arr[j][k] + " ");
}
}
}

What is printed when num has the value 14?

Answers

Answer 1

Answer:

Following are the complete code to the given question:

public class Main//main class

{

public static void main(String[] args) //main method

{

    int [][] arr = {{11, 13, 14 ,15},{12, 18, 17, 26},{13, 21, 26, 29},{14, 17, 22, 28}};//defining a 2D array

    int num=14;//defining an integer variable that holds a value 14

       for (int j = 0; j < arr.length; j++)//defining for loop to hold row value

       {

       for (int k = 0; k < arr[0].length; k++)//defining for loop to hold column value

       {

           if (arr[j][k] == num)//defining if block that checks num value

           {

               System.out.print(j + k + arr[j][k] + " ");//print value

           }

       }

       }

}

}

Output:

16 17

Explanation:

In the question, we use the "length" function that is used to finds the number of rows in the array. In this, the array has the 4 rows when j=0 and k=2 it found the value and add with its index value that is 0+2+14= 16.similarly when j=3 and k=0 then it found and adds the value which is equal to 3+0+14=17.So, the output is "16,17".  

Related Questions

A pharmaceutical company is going to issue new ID codes to its employees. Each code will have three letters followed by one digit. The letters and and the digits , , , and will not be used. So, there are letters and digits that will be used. Assume that the letters can be repeated. How many employee ID codes can be generated

Answers

Answer:

82,944 = total possible ID's

Explanation:

In order to find the total number of combinations possible we need to multiply the possible choices of each value in the ID with the possible choices of the other values. Since the ID has 3 letters and 1 digit, and each letter has 24 possible choices while the digit has 6 possible values then we would need to make the following calculation...

24 * 24 * 24 * 6 = total possible ID's

82,944 = total possible ID's


Landing pages in a foreign language should never be rated fully meets?

Answers

Answer:

if the landing page provides all kind information of information as to that site people usually like it or will most likely enjoy it

BRAINLIEST?????

Explanation:

Write a program second.cpp that takes in a sequence of integers, and prints the second largest number and the second smallest number. Note that in the case of repeated numbers, we really mean the second largest and smallest out of the distinct numbers (as seen in the examples below). You may only use the headers: and . Please have the output formatted exactly like the following examples: (the red is user input)

Answers

Answer:

The program in C++ is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

   int n;

   cout<<"Elements: ";

   cin>>n;

   vector <int>num;

   int input;

   for (int i = 1; i <= n; i++){        cin>>input;        num.push_back(input);    }

   int large, seclarge;

   large = num.at(0);      seclarge = num.at(1);

  if(num.at(0)<num.at(1)){     large = num.at(1);  seclarge = num.at(0);   }

  for (int i = 2; i< n ; i ++) {

     if (num.at(i) > large) {

        seclarge = large;;

        large = num.at(i);

     }

     else if (num.at(i) > seclarge && num.at(i) != large) {

        seclarge = num.at(i);

     }

  }

  cout<<"Second Largest: "<<seclarge<<endl;

  int small, secsmall;

  small = num.at(1);       secsmall = num.at(0);

  if(num.at(0)<num.at(1)){ small = num.at(0);  secsmall = num.at(1);   }

  for(int i=0; i<n; i++) {

     if(small>num.at(i)) {  

        secsmall = small;

        small = num.at(i);

     }

     else if(num.at(i) < secsmall){

        secsmall = num.at(i);

     }

  }

  cout<<"Second Smallest: "<<secsmall;

  return 0;

}

Explanation:

See attachment for explanation

Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lower even number.

Answers

Answer:

if(n % 2 == 0){

   for(int i = n; i >= 0; i-=2){

        System.out.println(i);

    }

}

else{

     for(int i = n - 1; i >= 0; i-=2){

        System.out.println(i);

     }

}

Sample output

Output when n = 12

12

10

8

6

4

2

0

Output when n = 21

20

18

16

14

12

10

8

6

4

2

0

Explanation:

The above code is written in Java.

The if block checks if n is even by finding the modulus/remainder of n with 2.  If the remainder is 0, then n is even. If n is even, then the for loop starts at i = n. At each cycle of the loop, the value of i is reduced by 2 and the value is outputted to the console.

If n is odd, then the else block is executed. In this case, the for loop starts at i = n - 1 which is the next lower even number. At each cycle of the loop, the value of i is reduced by 2 and the value is outputted to the console.

Sample outputs for given values of n have been provided above.

When parameters are passed between the calling code and the called function, formal and actual parameters are matched by: a.

Answers

Answer:

their relative positions in the parameter and argument lists.

Explanation:

In Computer programming, a variable can be defined as a placeholder or container for holding a piece of information that can be modified or edited.

Basically, variable stores information which is passed from the location of the method call directly to the method that is called by the program.

For example, they can serve as a model for a function; when used as an input, such as for passing a value to a function and when used as an output, such as for retrieving a value from the same function. Therefore, when you create variables in a function, you can can set the values for their parameters.

A parameter can be defined as a value that must be passed into a function, subroutine or procedure when it is called.

Generally, when parameters are passed between a calling code and the called function, formal and actual parameters are usually matched by their relative positions in the parameter and argument lists.

A formal parameter is simply an identifier declared in a method so as to represent the value that is being passed by a caller into the method.

An actual parameter refers to the actual value that is being passed by a caller into the method i.e the variables or values that are passed while a function is being called.

To iterate through (access all the entries of) a two-dimensional arrays you
need for loops. (Enter the number of for loops needed).

Answers

Answer: You would need two loops to iterate through both dimensions

Explanation:

matrix = [[1,2,3,4,5],

              [6,7,8,9,10],

              [11,12,13,14,15]]

for rows in matrix:

    for numbers in rows:

         print(numbers)

The first loop cycles through all the immediate subjects in it, which are the three lists. The second loop calls the for loop variable and iterates through each individual subject because they are lists. So the first loop iterates through the 1st dimension (the lists) and the seconds loop iterates through the 2nd dimension (the numbers in the lists).

To iterate through (access all the entries of) a two-dimensional arrays you need two for loops.

What is an array?

A collection of identically typed items, such as characters, integers, and floating-point numbers, are kept together in an array, a form of data structure.

A key or index that can be used to retrieve or change the value kept in that location identifies each element in the array.

Depending on how many indices or keys are used to identify the elements, arrays can be one-dimensional, two-dimensional, or multi-dimensional.

Two nested for loops are often required to iterate over a two-dimensional array: one to loop through the rows, and the other to loop through the columns.

As a result, two for loops would be required to access every entry in a two-dimensional array.

Thus, the answer is two for loops are required.

For more details regarding an array, visit:

https://brainly.com/question/19570024

#SPJ6

Other Questions
help me please!!!! asap Tia In order to assess whether an event should be considered a national-level event, the Department of Homeland Security uses a ____ threshold How many moles of aluminum are in 54 grams find the rule for the following geometric sequence: 4, -12, 36, -108, ....what is n7 can someone tell me these notes on clarinet please and ty HELP ASAPPPP, FIRST PERSON TO HAVE THE CORRECT ANSWER WILL HAVE BRAINLIEST What is the distance between points (8,3) and (3, 1) on the coordinate plane?OA. 3 unitsOB. 21 unitsOC.29 unitsOD. 7 units In London today, twice the low temperature was less than three timesthe low temperature minus ten. In interval form, what are the possibletemperatures? Martin is driving to his uncles farm, which is 240 mi. from home. If he drives at a constant rate of 60 mph, how long will it take Martin to get to the farm? A. 2 hr. B. 4 hr. C. 5 hr. D. 6 hr. Which of these are considered both short- and long-term investments? Select four options.CDsstockssavings accountsmutual fundsbondscommoditiesEdge answers please Does anyone know the answer Does President Biden want to ban red meat? 25) Margie needs to borrow $9,000 from a local bank. Theloan has a 8.5% interest rate for 4 years. What willMargie's monthly payment be?A) $ 221,850.00B) $3060.00C) $250.0D) $ 221.85 NO LINKS the picture below shows six quarters and two pennies. If this was brokendown into two separate groups, what would be the equivalent ratio to six-seconds? what do mars, pluto, and Jupiter have in common (science) in 8th grade. .Which statement describes how the U.S. tried to contain the influence of communism in Europe after World War II?The United States and the Soviet Union created an alliance.The United States gave economic assistance through the Marshall Plan.U.S. leaders encouraged attendance at the Paris Peace Conference.The Soviet Union established the "Iron Curtain". Consider two perfectly negatively correlated risky securities A and B. A has an expected rate of return of 10% and a standard deviation of 16%. B has an expected rate of return of 8% and a standard deviation of 12%. The risk-free portfolio that can be formed with the two securities will earn a(n) _____ rate of return. Which of the following underlined words in the sentences below has a less negative connotation than dangerous? A. The hikers miraculoulsly survived the perilous blizzard. B. While the crocodile appears to wear a smile, its motives are usually treacherous. C. The divers knew that if they lost oxygen, the results could be fatal. D. The sudden gust of wind put the tight-rope walker in a precarious position. Atoms are the most basic unit of matter. Two or more atoms from the same or different elements can combine to form molecules.Cells are the most basic unit of life. Cells are made up of many different types of molecules. Which of the following accurately shows higher levels of organization within organisms, from least complex to most complex? A. cells organs organ systems tissues organism B. cells tissues organs organ systems organism C. cells organ systems organs tissues organism D. cells organs tissues organ systems organism Identify who is correct Describe the mistake that was made Why did Lewis show the American flag