Advertisement
SuperDroidT

MAX_MIN_differenceOfanArray

Jun 7th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. int main()
  5. {
  6.     int n[5] = {2,5,3,6,8};
  7.     int max = n[0], min = n[0];
  8.     int i;
  9.     for(i=0; i<5; i++)
  10.     {
  11.         if(max < n[i])
  12.             max = n[i];
  13.         else if (min > n[i])
  14.             min = n[i];
  15.     }
  16.     int div = max - min;
  17.     printf("%d - %d = %d",max,min, div);
  18.     getch();
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement