Advertisement
Umme_nishat

algorithom4

Jun 28th, 2020
1,691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2.     void main()
  3.     {
  4.  
  5.         int i, j, a, n, k[50];
  6.         printf("Enter the value of N \n");
  7.         scanf("%d", &n);
  8.  
  9.         printf("Enter the numbers \n");
  10.         for (i = 0; i < n; ++i)
  11.             scanf("%d", &k[i]);
  12.  
  13.         for (i = 0; i < n; ++i)
  14.         {
  15.  
  16.         for (j = i + 1; j < n; ++j)
  17.             {
  18.  
  19.                 if (k[i] > k[j])
  20.  
  21.                 {a =  k[i];
  22.                     k[i] = k[j];
  23.                     k[j] = a;
  24.  
  25.                 }
  26.  
  27.             }
  28.  
  29.         }
  30.  
  31.         printf("The numbers arranged in ascending order are given below \n");
  32.         for (i = 0; i < n; ++i)
  33.             printf("%d\n", k[i]);
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement