Array In Ascending Order

Introduction
  • The array in an ascending order is often necessary to arrange the elements in an array in the numerological order i.e. from the lowest values to the highest values. 
Software Requirements
  • Turbo C++ OR C. 
Programming
  1. ** ** ** ** ** ** ** ** ** ** ** ** ** ** * Array in ascending order ** ** ** ** ** ** ** ** ** ** ** ** ** ** **   
  2. #include < stdio.h > void main()  
  3. {  
  4.         int i, j, a, n, number[30];  
  5.         printf("Enter the value of N \n");  
  6.         scanf("%d", & n);  
  7.         printf("Enter the numbers \n");  
  8.         for (i = 0; i < n; ++i) scanf("%d", & number[i]);  
  9.         for (i = 0; i < n; ++i) {  
  10.             for (j = i + 1; j < n; ++j)  
  11.             {  
  12.                 if (number[i] > number[j])  
  13.                 {  
  14.                     a = number[i];  
  15.                     number[i] = number[j];  
  16.                     number[j] = a;  
  17.                 }  
  18.             }  
  19.             printf("The numbers arranged in ascending order are given below \n");  
  20.             for (i = 0; i < n; ++i) printf("%d\n", number[i]);  
  21.         }   
programming
 
programming

Explanation
  • In the programming, given above, I have clearly explained and the array in an ascending order is printed.
Output

Output

Conclusion
  •  Thus, the array in an ascending order has printed and executed successfully from the lowest to the highest value.