Ascending Order Program in C Using If Else

Ascending order program in c. This program will sort the array elements in the ascending order in output.

Putting numbers in ascending order means starting with the smallest and working your way up to the highest

void main()
int i,j,n,a[100],temp;
printf("Enter the number of elements\n");
scanf("%d",&n) ;
printf("Enter the elements\n");
printf("After Ascending order\n");
printf("%d ",a[i]);



Enter the number of elements


Enter the elements

54 1 67 89 54 After Ascending order 1 54 54 67 89

Sorting in C Program

Sorting is the process of putting items in ascending (or descending) order.

When people realised how important it was to find information quickly, they coined the term sorting.

The method of organising integers from smallest to largest from left to right is known as ascending order in mathematics.

It can also refer to organising letters or words from A to Z in alphabetical order.

Ascending means “up,” hence ascending order indicates that the numbers are increasing.

Temp Variable in C

A temporary variable is a variable in computer programming that has a brief lifetime and is used to retain data that will be removed quickly or before it can be stored in a more permanent memory location.

It’s commonly stated as a local variable, or a variable with local scope, because it’s short-lived.

A temp variable is a temporary variable that can be used in a C program to swap two numbers or temporarily assign any value.

For Loop to Execute Ascending Order Program in C

In the C programming language, the for loop is used to iterate statements or parts of a program numerous times.

It is commonly used to traverse data structures such as an array and a linked list.

A for-loop, or simply for loop, is a control flow statement in computer science that specifies iteration and allows code to be executed repeatedly.

While while-loops increment and test a loop variable, for-loops can be regarded of as short hands for while-loops.