Shishu

random creation in c

Oct 5th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int array[100],n=10,c,d,temp,swap;
  5.     srand(time(NULL));
  6.  
  7.     for(c=0;c<=10;c++)
  8.         array[c]=rand()%50+50;
  9.  
  10.     for(c=0;c<=9;c++)
  11.     {
  12.        temp=c;
  13.         for(d=c+1; d<n;d++)
  14.         {
  15.             if(array[temp]>array[d])
  16.                 temp=d;
  17.         }
  18.         swap = array[c];
  19.         array[c] = array[temp];
  20.         array[temp] =swap;
  21.     }
  22.     for(c=0;c<n;c++)
  23.         printf("%d\n",array[c]);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment