Saturday, April 23, 2022

Ascending order in Array in C Programming

 #include <stdio.h>

void main (){

   int num[20];

   int i, j, a, n;

   printf("Number of array : ");

   scanf("%d", &n);

   printf("Enter Random numbers : ");


   for (i = 0; i < n; ++i)    

      scanf("%d", &num[i]);


   for (i = 0; i < n; ++i){       

      for (j = i + 1; j < n; ++j){

          

         if (num[i] > num[j]){

            a = num[i];

            num[i] = num[j];

            num[j] = a;

         }

      }

   }

   printf("Ascending order :\n");

   for (i = 0; i < n; ++i){

      printf("%d\n", num[i]);

   }

}


No comments:

Post a Comment

How to install and configure Oracle Apex 24.1 with ORDS 22, Tomcat 9 and Jasper Report 7 on Oracle Linux 8.10

#########################Install Oracle  APEX 24.1################################ ----------------------------------------------------...