int lastLargestIndex(int a[],int n) //a=array, n= number of elements in array
{
int max=a[0],maxp=0; //max=largest no., maxp= position of largest no.
for(int i=0;i<n;i++)
if(a[i]>=max)
{
max=a[i];
maxp=i;
}
return maxp;
}
Assume the first element is the largest and store its value. Then traverse the remainder of the list, one element at a time. If the current element's value is larger than the stored value, overwrite the stored value with the current element's value. Once you've traversed the list, the stored value will hold the largest value.
MAX
You have the sort() method of Javascript arrays:---var a = [1,2,10,11];a.sort(); // gives [1, 10, 11, 2]---The default sort is lexicographic, sorting the values as strings.For numbers and descending sort, you can pass in a function:---function sortNum(a, b) {return a - b;}function sortDesc(a, b) {return b - a;}a.sort(sortNum); // gives [1, 2, 10, 11]a.sort(sortDesc); // gives [11, 10, 2, 1]---The function takes two arguments, and returns a negative number if the first element is smallest, a positive number if the first element is largest, and zero if they are equal.See related link.
/* using ellipses (...) to indicate tabs for clarity */ double largest (double *array, int M, int N) { ... int i, j; ... double *element; ... double answer = array[0][0]; ... for (i=0; i<M; i++) { ... ... for (j=0; j<N; j++) { ... ... ... element = array + i*M + j; ... ... ... if (*element > answer) answer = *element; ... ... } ... } ... return 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 }
The element with the largest number of nucleons is oganesson.
What is the element named for the sixth-largest continent?
#include<stdio.h> #include<conio.h> main() { int a[100]; int n,largest,index,position; printf("enter the number of elements in the array"); scanf("%d",&n); printf("enter %d elements",n); for(index=0;index<n;index++) scanf("%d",&a[index]); largest=a[0]; position=0; for(index=1;index<n;index++) if(a[index]>largest) { largest=a[index]; position=index; } printf("largest element in the array is %d\n",largest); printf("largets element's position in the array is %d\n",position+1); getch(); }
Iron, Fe, is the 4th largest element found on the lithosphere.
francium has the largest ionic radius
After carbon, The element having largest number of compounds is Hydrogen.
The largest human organ is the skin and it's function is to protect you.
Element hassium has the largest Atomic Mass.
Manganese is a metal element. It shows the largest oxidation number.
Radon
There is no element with atomic number 202. Element 118 is the largest made at the moment.
It is supposed to be francium. but since it is radioactive and less stable, cesium is generally considered to the be element with largest size.