**C program to** **sort array in ascending order** is to sort the given array in ascending order.

**What is sorting?**

It is technique to sort array or arrange data in some order either ascending or descending order.

**Example :-**

array [] = 30, 10, 20

Sorted list in ascending order is

array [] = 10, 20, 30

## Algorithm to sort array in ascending order

- Declare variables. N, a[]
- Take array input from a user. a[N]
- Traverse array

For i=0 to end

If a[i] > a[i+1]

swap a[i] and a[i+1]

Else continue - If a[i]== end

stop - Print sorted array

## C program to sort array in ascending order

#include<stdio.h> main() { int i,j,num,temp; printf("Enter number of elements\n"); scanf("%d",&num); int a[num]; printf("Enter numbers\n"); for(i=0;i<num;i++) { scanf("%d",&a[i]); } for(i=0;i<num;i++) { for(j=i+1;j<num;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } printf("Ascending oreder of given numbers is\n"); for(i=0;i<num;i++) { printf("%d\n",a[i]); } }

**Output :**