answersLogoWhite

0


Best Answer

A row is just a one-dimensional array so, given a pointer to the first element of a row of doubles and the number of doubles in the row, we can use the following algorithm:

// returns the largest double in an array of size count

double get_largest (double * p, unsigned count) {

if (p==NULL size==0) { /* invoke invalid argument handler */ }

double result = *p; // store first value in row (dereference the pointer)

while (--count) { // repeat for the remainder of the row

++p; // advance to the next element

if (*p > result) result = *p; // if the current element is larger, update stored value

}

return result; // return largest value

}

User Avatar

Wiki User

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to find the largest element in a row?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

The place in a spreadsheet where a row and a column intersect is called a?

A cell. In the periodic table an element fills that cell.


How do you initialize each element of a two-dimensional array alpha to 5?

Two-dimensional arrays are typically iterated through using nested for loops. If you had a 2-D array alpha with ints ROWS and COLS representing the number of rows and columns respectively, and ints row and col as iterators, the loop would look like this: for (row = 0; row < ROWS; row++){ for (col = 0; col < COLS; col++{ alpha[row][col] = 5; } }


How will you initialize a three-dimensional array thread 323. How will you refer the first and last element in this array?

The first element will be 0,0,0 and the last will be 2,1,2. It's always best to think of multi-dimensional arrays in terms of a one-dimensional array. That is, a 3x2x3 array is really a one-dimensional array of 3 elements (the first dimension), where each element is a 2x3 two-dimensional array, and where each of those 2x3 arrays is a one-dimensional array of 2 elements (the second dimension), where each element is a one-dimensional array of 3 elements (the third dimension). Thinking in these terms makes it much easier to visualise arrays with 4 or more dimensions. Arrays are always allocated contiguously, one element after the other. So the memory layout for your three dimensional array is as follows (where 000 means element 0,0,0): {{000, 001, 002}, {010, 011, 012}}, {{100, 101, 102}, {110, 111, 112}}, {{200, 201, 202}, {210, 211, 212}} The curly braces are merely notational, but they help to visualise the layout more clearly, dividing the memory into three groups of two groups of three elements. However, if we stack the three main groups one above the other it will be much easier to see visualise the structure: {000, 001, 002}, {010, 011, 012} {100, 101, 102}, {110, 111, 112} {200, 201, 202}, {210, 211, 212} If you look at each row you can clearly see that the first digit in each element is the same throughout that row. However, each row is really a two-dimensional array (of 2x3 elements), so each row is really a 2x3 table. The top row is therefore table 0, the middle row is table 1 and the bottom row is table 2. Let's look at table 0 more closely: Table 0: {000, 001, 002}, {010, 011, 012} Now let's stack the table's 2 elements so we can see the table more clearly: Table 0: {000, 001, 002} {010, 011, 012} Now the rows are identified by the second digit, where the top row is row 0 and the bottom row is row 1. Each row has three elements and the third digit identifies the column of that element (0, 1 or 2). Here's the complete structure: Table 0: Row 0: {000, 001, 002} Row 1: {010, 011, 012} Table 1: Row 0: {100, 101, 102} Row 1: {110, 111, 112} Table 2: Row 0: {200, 201, 202} Row 1: {210, 211, 212} From this we can clearly see that we can refer to any individual element through a table identifier (0, 1 or 2), a row identifier (0 or 1) and a column identifier (0, 1 or 2). Therefore to initialise this structure, we need to cycle through each identifier in turn. Here's how we do that using pseudo-code: given array A [3,2,3] for each table in 0 to 2 for each row in 0 to 1 for each column in 0 to 2 initialise A [table, row, column] next column next row next table


Find out the address of the element A452 where A is a 3-dimensional array with subscript limits 1 you 6 1 j 7 and 0 k 4 when A is in row major addressing Assume base address is 1000 and word size is 2?

1. Find out the address of the element A(4,5,2) where A is a 3-dimensional array with subscript limits 1≤ i ≤6, 1≤ j ≤7 and 0≤ k ≤4 when A is in row major addressing. Assume base address is 1000 and word size is 2.Answer:Array(depth,col,row) means A(4,5,2)Address= BASE+ ((depthindex*col_size+colindex) * row_size + rowindex) * Element_SizeADDRESS=1000+((4*7+5)*5+2)*2(1000+((33*5)+2)*2(1000+(167*2))(1000+334)1334


How do you draw pascals triangle in gwbasic?

I suggest using an array with as many elements as the longest row you need. To keep it simple, keep two copies of the array, and calculate each element of the "new" array as the sum of the corresponding element, plus the previous element, of the "old" array. Then copy the information back for the next step.

Related questions

Which element in row 6 of the peroidic table has the largest radius?

Cesium


Which element in the row 6 of the periodic table has the largest radious?

Caesium (At no. 55).


What is the determinant of a two-by-two matrix?

To find that, you multiply the first element of the first row by the second element of the second row. You also multiply the first element of the second row with the second element of the first row. Then you subtract the products not add them.


Largest element in a row and largest element in a column?

The largest element in a Period (row) will be on the right of that Period (i.e. an inert gas). The largest element in a Group (column) will be at the bottom of that group. Examples; Helium is larger than Hydrogen (Period 1) Krypton is larger than Potassium (Period 3) Francium is larger than Lithium (Group 1) Ununquadium is larger than Carbon (Group 3)


Which element in row 8 has the largest atomic radius?

there isn't an eighth row in the periodic table of elements. The two rows at the bottom that aren't connected are actually part of the sixth and seventh row. However, in a row, the last one on the far right would normally have the larger atomic radius.


How do you find the largest and smallest number row wise and column wise?

Use the function MAX to find the largest value. Use the function MIN to find the smallest value. If you want to find the value in a row, use the range of the cells in the row; for column, use the range of cells in the column. =MAX(A1:A12) will find the largest value in column A (from row 1 through 12). =MIN(A1:M1) will find the smallest value in row 1 (from column A through M).


What row is element helium?

it is in the first row


Where to find iron?

8th column and 4th row in the Transition Metals. Element number 26


What does the period number say about the elemnt?

It shows the horizonal row of the element so like Ex: Rb which is period 5 cause u count how many rows there is and when u find the element(He) it is in the 5th row


Where on the periodic table can you find an element that has the same chemical properties as another element but is more massive than that element?

In the same column (group) but in a row below the chemical you start with.


Which element is the largest K Rb Na Li?

Rb is the largest, Li the smallest in the row above. Group 1 of the periodic table: Fr > Cs > Rb > K > Na > Li > H


In which area of the periodic table would you find the element copper?

Transition metals, row 4, column 7.