posted Jan 7, 2011, 11:52 PM by Neil Mathew
[
updated Jan 8, 2011, 12:11 AM
]
SOURCE CODE:
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
| #include<stdio.h
void Ssort(int *a,int n)
{
int i,j,temp;
for(i=0; i<n-1; i++)
for(j=i+1; j<n; j++)
if(a[i]>a[j])
{
temp=a[i];;
a[i]=a[j];
a[j]=temp;
}
}
main()
{
int a[50],n,i;
printf("Enter size of your array: ");
scanf("%d",&n);
printf("Enter elements of your array: ");
for(i=0; i<n; i++)
scanf("%d",&a[i]);
Ssort(a,n);
printf("\nElements: \n");
for(i=0; i<n; i++)
printf("%d ",a[i]);
} |
OUTPUT:
Enter size of your array: 5
Enter elements of your array: 1 9 3 7 6
Elements:
1 3 6 7 9
|
|