forked from sabir9136/C-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram4.c
More file actions
39 lines (32 loc) · 649 Bytes
/
program4.c
File metadata and controls
39 lines (32 loc) · 649 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
#include<stdio.h>
#include<conio.h>
void sorting(int *x, int y);
void main()
{
int a[20], i, c, n;
clrscr();
printf("Enter number of elements you want to sort: ");
scanf("%d", &n);
for(i = 0; i < n; i++)
scanf("%d", &a[i]);
sorting(a, n);
for(i = 0; i <n; i++)
printf("%d\t", a[i]);
getch();
}
void sorting(int *x, int y)
{
int i, j, temp;
for(i = 1; i <= y-1; i++)
{
for(j = 0; j < y-i; j++)
{
if(*(x+j) > *(x+j+1))
{
temp = *(x+j);
*(x+j) = *(x+j+1);
*(x+j+1) = temp;
}
}
}
}