SHARE
TWEET

algorithom4

Umme_nishat Jun 28th, 2020 1,254 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top