answersLogoWhite

0


Best Answer

#include <stdio.h>

#include <conio.h>

int main()

{

int a[10],i,j,temp=0;

printf("Enter all the 10 numbers");

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

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

for(i=0;i<10;i++) //This loop is for total array elements (n)

{

for(j=0;j<9;j++) //this loop is for total combinations (n-1)

{

if(a[j]>a[j+1]) //if the first number is bigger then swap the two numbers

{

temp=a[j];

a[j]=a[j+1];

a[j+1]=temp;

}

}

}

printf("The ordered array is");

for(j=0;j<10;j++) //Finally print the ordered array

printf("%d \t",a[j]);

getch();

return 0;

}

User Avatar

Wiki User

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

Wiki User

12y ago

sort (int N, int *A) {

int i, swap = 1;

while (swap) {

swap = 0;

for (i=0; i<N-1; ++i) {

if (A[i] > A[i+1]) {

swap = 1;

A[i] ^= A[i+1];

A[i+1] ^= A[i];

A[i] ^= A[i+1];

}

}

}

return;

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

what is c laungagee?????e

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

Use a std::list with std::sort.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a program in linked list in ascending and descending order in sorted way using c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are 3 examples of data being sorted in descending and ascending order?

Any data that is keyed to a numeric or text field may be sorted in ascending or descending order. Data that is keyed to a date may be sorted in chronological order (ascending with oldest first) or reverse-chronological order (descending order with newest first). Data that is keyed to a price may be sorted with most-expensive first (descending order) or least-expensive first (ascending order). Data that is keyed to a weight may be sorted in ascending or descending order of weight. And so on.


You can sort numeric fields in ascending order only?

No. They can be sorted either ways. Ascending or Descending.


Sort array in ascending descending order in python?

Using sorted(array,reverse=True)


What advantages of a sorted list over a linked list?

All lists are linked lists; there is no such thing as a separate "sorted list". There are algorithms that can sort a list, of course, but they all work on linked lists.


Given a linked list of integers sorted in an ascending order and a pointer to a single node containing an integer write a C program that insert the node P in the linked list so that remains sorted?

InsertNode(NODE **q,int num) { NODE *r,*temp ; temp = *q; r= malloc(sizeof(NODE)); r-&gt;data = num; //if it's fisrt node to be inserted if ( *q == NULL num &lt; (*q)-&gt;data) { *q = r ; (*q)-&gt;link=temp; } else { while(temp) { if ( (num &gt; temp-&gt;data) &amp;&amp; (num &lt; temp-&gt;link-&gt;data ) ) { r-&gt;link = temp-&gt;link; temp-&gt;link = r; return; } temp = temp-&gt;link; } r-&gt;link = NULL; temp-&gt;link = r; } }

Related questions

Can Data can only be sorted in ascending order.?

No, it can be sorted either in ascending or descending order.


Can Data only be sorted in ascending order?

No, it can be sorted either in ascending or descending order.


What are 3 examples of data being sorted in descending and ascending order?

Any data that is keyed to a numeric or text field may be sorted in ascending or descending order. Data that is keyed to a date may be sorted in chronological order (ascending with oldest first) or reverse-chronological order (descending order with newest first). Data that is keyed to a price may be sorted with most-expensive first (descending order) or least-expensive first (ascending order). Data that is keyed to a weight may be sorted in ascending or descending order of weight. And so on.


You can sort numeric fields in ascending order only?

No. They can be sorted either ways. Ascending or Descending.


Sort array in ascending descending order in python?

Using sorted(array,reverse=True)


What is the difference between ascending and descending order?

Ascending means increasing (usually numbers but could be alphabetic). Descending is the opposite. 81, 121, 100, 169, 11, 9, 14; sorted in ascending order is: 9, 11, 14, 81, 100, 121, 169. The letters Q A B T U Y G H, sorted in descending order are: Y U T Q H G B A


Which of the following columns can be sorted by clicking on the ascending and descending arrows on the column header row?

Effective Date


Can only be sorted in ascending order?

There is nothing that can only be sorted in ascending order - unless the sorting is being done as the data are being generated.


If a list of words is sorted alphabetically in word then it is in blank order?

It will be sorted in ascending order.


What is ascending in Excel?

Ascending is an order in which things can be sorted. Ascending would be going from A to Z or lowest to highest numbers or earliest to latest dates.


What is the use of the SQL sort?

The use of sorting information in SQL is to organize database query results. Typically the data can be sorted in either ascending or descending order. The "Order By" command can be used to sort data in SQL by multiple columns.


Place the smallest number of significant digits at the top and the largest number at the bottom of the column?

Placing the smallest digit at the top and listing so the digits continue down to the largest number is to sort in ascending order, from, for example, 1 to 10.To place the numbers with the largest at the top and the smallest at the bottom is to sort in descending order, say from 10 to 1.These terms also apply to other sorted data, so a column of words, for example, might be sorted alphabetically in either ascending or descending order, with the first letters listed from A to Z, or from Z to A.