answersLogoWhite

0


Best Answer

#include

#include

#include

#include

void main()

{

clrscr();

int n,i,term,j;

int x[100];

printf("/nEnter no. of terms (N) " );

scanf("%d",&n);

for(i=0;i

{

printf("n/Enter %d element",i+1);

scanf("%d", &x[i]);

}

printf("/given arrary is");

for(i=0;i

printf("/n %d",x[i]);

for(i=0;i

for(j=i+1;j

if(x[i]

{

term = x[i];

x[i] = x[j];

x[j] = term;

}

printf("/nSorted array is given below");

for(i=0;i

printf("/n%d",x[i]);

getch();

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

#include <stdio.h>

#include <conio.h>

void main()

{

int n ,i,j,temp,a[12]; //in a[] specify some number .

printf("Enter the no of inputs:");

scanf("%d", &n);

printf("Enter %d integer numbers :", n);

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

{

scanf("%d",&a[i]);

}

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

for(j=i+1;j<n;j++)

{

if(a[i]>a[j])

{

temp=a[j];

a[j]=a[i];

a[i]=temp;

}

}

printf("THE %d NUMBERS SORTED IN ASCENDING ORDER ARE :\n", n);

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

{

printf("%d ",a[i]);

}

getch();

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

void sortints(int *list, listsize){
int n;
for(n = 1; n < listsize; n++){
if(list[n] > list[n - 1]){
list[n - 1] ^= list[n];
list[n] ^= list[n - 1];
list[n - 1] ^= list[n];
if(n > 1) n -= 2;

}

}

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C code to sort array of integers in descending order?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you read one dimensional array of integers for highest integer?

Sample code is as follows: #include &lt;stdio.h&gt; void main() { int i = 0; int final_number = 0; int array[] = {-2,-6,2,4,1,6,8,20,-55}; for(i = 0; i &lt; (sizeof(array)/sizeof(array[0])); i++) { if(array[i] &gt; array[i + 1]) final_number = array[i]; } printf("%d", final_number); } Tried in MinGw: Output: 20


How can one assign a list of integers in Java?

Put statements at the start of ones code will allow one to have a list of integers in their Java program. If one does this then they will successfully have integers in their code.


An array of array can be created in java?

Yes. int[][] as; // this will define an array of arrays of integers Multidimensional arrays, remember, are simply arrays of arrays. So a two-dimensional array of type int is really an object of type int array (int []), with each element in that array holding a reference to another int array. The second dimension holds the actual int primitives. The following code declares and constructs a two-dimensional array of type int: int[][] myArray = new int[3][]; Notice that only the first brackets are given a size. That's acceptable in Java, since the JVM needs to know only the size of the object assigned to the variable myArray.


Create a mark list using array with structure?

sorce code for student mark list usig array


What the code for ptca of left anterior descending coronary artery?

00.66 36.06


How do you sort the given contents of an array?

You would sort the given elements of an array by a bubble sort or heap sort code!!


What are the 4 an invalid BCD code?

BCD code isn't valid for these integers , 10 , 11 , 12 , 13 , 14 i.e if these integers ae converted to binary code they 'd be called wrong BCD


Can you help me with the C plus plus code of the program which has 10 index of array it adds 5 into every even elements of the array and then it subtracts 10 into the odd elements of the array?

int array[10] = {...}; for (int i = 0; i &lt; 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }


How 2 write c code of array data structure?

An example: int array [10]; yaaa this is write but for a simple programs on array and all data structure visit codingdatastructure.blogspot.com


How do you convert decimal to gray code?

In order to convert decimal to gray code use an array of int containing either a one or a zero at each position. A BitArray could also be used and might be a better choice.


What diagnosis code do you use with cpt code 63650?

CPT Code 63650 - Percutaneous implantation of neurostimulator electrode array, epidural


What is the Fibonacci code used for?

In mathematics, Fibonacci coding is a universal code which encodes positive integers into binary code words