Advertisement
tonygms3

Question 6 Assignment

Dec 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int num[10]={5,4,3,7,1,150,45,1547,857,2};
  5.     int i=0,j=0,temp=0,k=0;
  6.     for(i=0;i<=9;i++)
  7.     {
  8.         for(j=i+1;j<=9;j++)
  9.         {
  10.             if(num[i]>num[j])
  11.             {
  12.                 temp=num[i];
  13.                 num[i]=num[j];
  14.                 num[j]=temp;
  15.             }
  16.         }
  17.     }
  18.     printf("The array is\t");
  19.     for(k=0;k<=9;k++)
  20.     {
  21.         printf("%d ",num[k]);
  22.     }
  23.  
  24.     printf("\n\nThe range is the difference between %d - %d which is : %d",num[0],num[9],(num[9]-num[0]));
  25.     printf("\n\n");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement