Advertisement
horselurrver

Largest Number

Aug 4th, 2016
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int largest(int array[], int size);
  4.  
  5. int main(void){
  6.     int array1[]={1,2,3,4,5,6,7,8,9,10,1234,90,12,342,1324,12,34,234,19};
  7.     printf("The largest number in the array is %d.\n", largest(array1, 19));
  8.    
  9.     return 0;
  10.    
  11. }
  12.  
  13. int largest(int array[], int size){
  14.     int *ptr;
  15.     int i;
  16.     int biggest=-32768;
  17.     ptr=array;
  18.     for(i=0; i<size; i++){
  19.         if (*ptr>biggest){
  20.             biggest=*ptr;
  21.         }
  22.        
  23.         ptr++;
  24.     }
  25.    
  26.    
  27.     return biggest;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement