t805

Maximum Value Of An Int Array

Sep 10th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. const int SIZE = 8;
  4.  
  5. int main()
  6. {
  7.     int array[SIZE] = {-20, 19, 1, 5, -1, 27, 19, 5};    
  8.     int max;
  9.     int i;
  10.  
  11.     max = array[0];
  12.    
  13.     for(i = 1; i < SIZE; i++)
  14.     {
  15.         if(array[i] > max)
  16.             max = array[i];
  17.     }
  18.  
  19.     printf("The maximum of this array is: %d\n", max);
  20.  
  21.     return(0);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment