-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsorting.c
More file actions
28 lines (25 loc) · 1.66 KB
/
sorting.c
File metadata and controls
28 lines (25 loc) · 1.66 KB
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
#include<stdio.h>
void sort(int m, int x[ ]);
main() {
int i;
int marks[5] = {40, 90, 73, 81, 35};
printf("Marks before sorting\n");
for(i = 0; i < 5; i++)
printf("%d ", marks[i]);
printf("\n\n");
sort (5, marks);
printf("Marks after sorting\n");
for(i = 0; i < 5; i++)
printf("%4d", marks[i]);
printf("\n");
}
void sort(int m, int x[ ]) {
int i, j, t;
for(i = 1; i <= m-1; i++)
for(j = 1; j <= m-i; j++)
if(x[j-1] >= x[j]) {
t = x[j-1];
x[j-1] = x[j];
x[j] = t;
}
}