- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSort_Array.cpp
More file actions
Latest commit
28 lines (23 loc) · 602 Bytes
/
Copy pathSort_Array.cpp
File metadata and controls
28 lines (23 loc) · 602 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
#include<stdio.h>
#include<conio.h>
voidmain()
{
int i, j, no_terms, a[10], temp;
printf("Enter the Number of Elements of the Array :: ");
scanf_s("%d", &no_terms);
printf("\nEnter the Elements of the Array :: ");
for (i = 0;i < no_terms;i++)
scanf_s("%d", &a[i]);
for (i = 0;i < no_terms-1;i++)
for (j = 0;j < no_terms - 1 - i;j++)
if (a[j] > a[j + 1])
{
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
printf("\nThe Elements of the Array afte Sorting are :: \n");
for (i = 0;i < no_terms;i++)
printf("%d\t", a[i]);
_getch();
}