Computer Science, asked by pinalpatel5764, 10 months ago

Process of placing elements from a collection in some kind of order

Answers

Answered by amitnrw
0

Process of placing elements from a collection in some kind of order ?

Sorting

Process of placing elements from a collection in some kind of order is called sorting.

Few examples of Sorting are :

Sorting can be done based on values in Ascending / Descending order

Alphabetically   A-Z  / Z-A

Custom rules can be defined to Sort the data

Sorting can be done on Days of week basis

Can also be done on basis of months of a year

Answered by siddhartharao77
0

Process of placing elements from a collection in some kind of order is called as "Sorting".

Sample Program to sort elements in Ascending order:

#include<stdio.h>

void main()

{

int c,d,e[50];

printf("Enter the value of n: ");

scanf("%d", &d);

printf("Enter numbers: ");

for(int i = 0; i < d; i++)

{

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

}

for(int i = 0; i < d; i++)

{

for(int j = i + 1; j < d; j++)

{

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

{

c = e[i];

e[i] = e[j];

e[j] = c;

}

}

}

printf("After sorting in ascending order: ");

for(int i = 0; i < d; i++)

printf("%d\n", e[i]);

}

Output:

Enter the value of n: 5

Enter numbers : 20 10 30 5 4

After sorting in ascending order:

4

5

10

20

30

Hope it helps!

Similar questions