answersLogoWhite

0


Best Answer
  1. #include
  2. #include
  3. int main()
  4. {
  5. long int sort[10],i,j,t;
  6. printf("\n\ n Enter 10 Elements In Array To Sort In Descending Order:\n"); for(i=0;i<10;i++)
  7. scanf("%ld",&sort[i]);
  8. for(i=0;i<10;i++)
  9. for(j=i+1;j<10;j++)
  10. if(sort[i]>sort[j])
  11. {
  12. t=sort[i]; sort[i]=sort[j];
  13. sort[j]=t;
  14. }
  15. printf("Array Elements in Descending Order Are :");
  16. for(i=9;i>=0;i--)
  17. {
  18. printf("%ld\n",sort[i]);
  19. }
  20. getch();
  21. return 0;
  22. }
User Avatar

Wiki User

βˆ™ 12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to solve the given array element in descending order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Given two arrays A and B Array?

distinguish extra element in two arrays


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


Which are the searching algorithm always compare the middle element with the searching elements in the given array?

binary search system


What is an element in the Array?

An array is a container object that holds a fixed number of values of a single type. ... Each item in an array is called an element, and each element is accessed by its numerical index. As shown in the preceding illustration, numbering begins with 0. The 9th element, for example, would therefore be accessed at index 8.


What is an array and what does index mean in an array in c?

An array is an aggregate of elements, where memory is allocated to accommodate a given number of elements of a given type. The name of the array serves as a reference to the first element of the array. Unlike ordinary (non-array) variables, all the other elements of an array have no name; they are anonymous. However, all elements of an array have identity (they have an address) so if we know the address of an element within an array we can easily refer to it by that address. Given that each element is of the same type and therefore the same size (in bytes), we can easily calculate the address of each element offset from the start of the array. That is, the nth element of an array A of type T will be found at address A + sizeof(T) * (n-1). Although we are free to use "pointer arithmetic" like this to calculate the individual addresses of each element, C provides us with a much more convenient notation called the array suffix operator. The array suffix operator applies to pointer variables only. Fortunately, all arrays implicitly convert to a pointer at the slightest provocation so we don't have to do anything special to use them. The operator is denoted using square brackets [] such that for an array A we can refer to its nth element as A[n-1]. Given that A is of type T, the compiler has enough information to generate the required pointer arithmetic for us: A + sizeof(T) * (n-1). Note that array indices are in the range 0 to n-1 for an array of n elements. Attempting to access elements outwith this range has undefined behaviour, so it is important that we take steps to ensure all indices are kept within the bounds of the array. For fixed-length arrays, we can simply use a constant to store the array length, but for variable-length arrays we must keep track of the length using a variable. To range-check a given index against a given length, n, the index must be in the closed range [0:n-1]. However, array index ranges are often denoted using half-closed notation, [0:n), which essentially means 0 &lt;= index &lt; n.

Related questions

Given two arrays A and B Array?

distinguish extra element in two arrays


Write a c program to find descending order of given elements in a list using arrays?

#include #include int main() { int a[20],i,j,n,temp; clrscr(); printf("\n Enter no. of elements for 1-D array : "); scanf("%d",&amp;n); for(i=0;i&lt;n;i++) { printf(" Enter element[%d] : ",i+1); scanf("%d",&amp;a[i]); } for(i=0;i&lt;n;i++) { for(j=i+1;j&lt;n;j++) { if(a[i]&gt;a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } printf("\n\n Decending order of inserted array is : "); for(i=0;i&lt;n;i++) { printf("\n %d ",a[i]); } getch(); return 0; } Output: Enter no. of elements for 1-D array : 5 Enter element [1] : 2 Enter element [2] : 10 Enter element [3] : 4 Enter element [4] : 13 Enter element [5] : 7 Decending order of inserted array is: 13 10 7 4 2


How do you write a program to read set of numbers using by an array and display the ascending order of the given input numbers?

To write a C++ program to display the student details using class and array of object.


Which are the searching algorithm always compare the middle element with the searching elements in the given array?

binary search system


What is an element in the Array?

An array is a container object that holds a fixed number of values of a single type. ... Each item in an array is called an element, and each element is accessed by its numerical index. As shown in the preceding illustration, numbering begins with 0. The 9th element, for example, would therefore be accessed at index 8.


What is an array and what does index mean in an array in c?

An array is an aggregate of elements, where memory is allocated to accommodate a given number of elements of a given type. The name of the array serves as a reference to the first element of the array. Unlike ordinary (non-array) variables, all the other elements of an array have no name; they are anonymous. However, all elements of an array have identity (they have an address) so if we know the address of an element within an array we can easily refer to it by that address. Given that each element is of the same type and therefore the same size (in bytes), we can easily calculate the address of each element offset from the start of the array. That is, the nth element of an array A of type T will be found at address A + sizeof(T) * (n-1). Although we are free to use "pointer arithmetic" like this to calculate the individual addresses of each element, C provides us with a much more convenient notation called the array suffix operator. The array suffix operator applies to pointer variables only. Fortunately, all arrays implicitly convert to a pointer at the slightest provocation so we don't have to do anything special to use them. The operator is denoted using square brackets [] such that for an array A we can refer to its nth element as A[n-1]. Given that A is of type T, the compiler has enough information to generate the required pointer arithmetic for us: A + sizeof(T) * (n-1). Note that array indices are in the range 0 to n-1 for an array of n elements. Attempting to access elements outwith this range has undefined behaviour, so it is important that we take steps to ensure all indices are kept within the bounds of the array. For fixed-length arrays, we can simply use a constant to store the array length, but for variable-length arrays we must keep track of the length using a variable. To range-check a given index against a given length, n, the index must be in the closed range [0:n-1]. However, array index ranges are often denoted using half-closed notation, [0:n), which essentially means 0 &lt;= index &lt; n.


How arrays are used in synon?

Synon array processing is totally intuitive for any synon user. You do not need to open a manual. If you can use a file, you can use an array. The main difference is that there are only 4 function types: CRTOBJ, CHGOBJ, DLTOBJ, RTVOBJ, and only 1 "ACP" (set of Key fields)The array processing really behaves more like an indexed file than an array. The file portion (Records) is a multiple occurrence data structure and the index portion is an array. The data structure contains the fields as defined in the *ARRAY file. The array(Index) is the fields defined as the Key concatenated with the occurrence# of the data structure. When you create an element in the array (a record in the file), the program takes the next available occurrence of the data structure and loads the fields. The program also creates the Index element by concatenating the key fields with the occurrence# of the newly added data structure. The program then does a Sort Array to sequence the Index so that the records may be accessed in key sequence. Any time a record is deleted, the Index element is blanked out and the Index is Sorted (Sort Array). This is a very clean solution and the performance is surprisingly good considering that the array is sorted after each add or delete.When accessing the data, a LOKUP is performed on the array using the key value with blanks instead of the occurrence# and looking for GT in the array. This allows processing of partial keys as positioners or restrictors. The program then reads the data structure for the occurrence# taken from the array element to get the data(fields). For the next occurrence, it is not necessary to do another LOKUP (which is slow) because the array is sorted. The program only has to read the next element in the array and continue the processing as long as the partial key matches the key in the array. From the point of view of the Synon user, this processing is identical to a file RTVOBJ.Synon loads the array from the bottom (an RPG technique to improve performance in large arrays) because the LOKUP command may be given a starting position, but cannot be stopped until every element is checked when no match is found. By loading the array backwards from the bottom and counting the elements, the search may be started at the last element loaded and only elements which contain data are read.IF No Match is FoundAn array is defined for 1000 elements.Only 10 elements are loaded.These are loaded to occurrences 991 thru 1000.When the LOKUP is performed, it starts at 991 and only 10 compares are made.** If the array is loaded from the top, 1000 compares are performed.


How 3d arrays are represented in memory?

All multi-dimensional arrays are represented as arrays of arrays. That is, each element of the array is itself an array. Thus a two-dimensional array can be thought of as being a one-dimensional array where every element is a one-dimensional array. A three-dimensional array is therefore a one-dimensional array of two-dimensional arrays. And so on. The actual memory layout of a multi-dimensional array is no different to that of a one-dimensional array of the same size: int a[12]; int b[3][4]; Assuming a 4-byte int, the amount of memory allocated to a is 12 x 4 = 48 bytes. The array b is essentially an array where each element holds an array of 4 integers, thus each element is 16 bytes in length. Given there are 3 such elements in total, the total size of b is 3 x 16 = 48 bytes, the same as was allocated to a. Although the allocations are exactly the same in terms of size, the layouts differ. The array a is an array of twelve 4-byte elements (of type int) whereas array b is an array of three 16-byte elements, each of which is itself an array of four 4-byte elements (of type int). This changes the way we refer to the individual elements of the array. Every element in an array is referred to by its offset address from the start of the array. This is determined by multiplying its zero-based index by the element size. In the case of a, every element is 4-bytes in length, thus element a[2] refers to the element that is offset 2 x 4 = 8 bytes from the start of the array. But in the case of b, however, b[2] would refer to the 16-byte element that is offset 2 x 16 = 32 bytes from the start of the array. Given that we're actually referring to an element which is itself a 4-element array, we must use a second subscript to refer to the elements of that array. Thus b[2][3] would refer to the integer that is offset 3 x 4 bytes from the start of the array referred to by b[2]. Extending this idea into three-dimensions is simply a matter of taking a third subscript into account.


What is C implementation of queues?

It depends on the type of data, but generally you would just implement a data array and have a static pointer to the "next" element of the array and a static pointer to the "last" element of the array. New data would be added to the location of the "last" pointer. Data would be processed from the "next" pointer. Pointers would be incremented to the appropriate element whenever reading or writing and special attention given to any time you come to the end of the array.


C program to fine the largest of 10 given number?

first sort the ten numbers in descending order and print the first number. That will be the largest no


Write a java program to find sum of even and odd numbers in given array?

for(int i = 1; i &lt; 100; i+=2) { System.out.println(i); }


Index of an element in array?

An array is a group of related elements, with a common variable name. The index is a number that indicates the position of an element within an array: the 1st. element, the 2nd. element, etc. (many languages start counting at zero).