# Sort Array in Ascending Order C Program

By | November 16, 2015

## C Program To Sort Array in Ascending Order

Learn How To Sort Array in Ascending Order in C Programming. It is important that we should know How A For Loop Works before getting further with the C Program Code. This Array Sorting C Program is basically done on a 1 – Dimensional Array. The Code For Sorting Arrays with Ascending Order method is executed using For Loops.

Also Read: C Program To Find Roots of Quadratic Equations

#### C Program To Sort Array in Ascending Order using For Loop

```#include<stdio.h>

int main()
{
int arr, temp;
int limit, i, j;
printf("\nEnter the size of the array: \t");
scanf("%d", &limit);
for(i = 0; i < limit; i++)
{
printf("Enter Element %d:\t", i + 1);
scanf("%d", &arr[i]);
}
printf("\nArray\n");
for(i = 0; i < limit; i++)
{
printf("%d\t", arr[i]);
}
for(i = 0; i < limit; i++)
{
for(j = 0; j < limit; j++)
{
if(arr[i] < arr[j])
{
temp = arr[j];
arr[j] = arr[i];
arr[i] = temp;
}
}
}
printf("\nSorted Array\n");
for(i = 0; i < limit; i++)
{
printf("%d\t", arr[i]);
}
printf("\n");
return 0;
}```

Also Read: Find Sum of Lower Triangular Elements in C Programming

#### Output

If you have any compilation errors or doubts in this C Program To Sort Array Elements in Ascending Order, let us know about it in the Comment Section below.