-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsorting.c
More file actions
44 lines (40 loc) · 842 Bytes
/
sorting.c
File metadata and controls
44 lines (40 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <conio.h>
int sorting(int *x,int n)
{
int i,j,t;
for(i=0; i<n; i++)
{
for(j=i; j<n; j++)
{
if(x[i]>x[j])
{
t=x[i];
x[i]=x[j];
x[j]=t;
}
}
}
}
int main()
{
int x[100],n,i;
printf("\n Enter the no of the array element :- ");
scanf("%d",&n);
for(i=0; i<n; i++)
{
printf("\n Enter the %d array element = ",i);
scanf("%d",&x[i]);
}
printf("\n\n Before sorting array elements are :- ");
for(i=0; i<n; i++)
{
printf(" %d",x[i]);
}
sorting(x,n);
printf("\n\n After sorting array elements are :- ");
for(i=0; i<n; i++)
{
printf(" %d",x[i]);
}
}