18126

Day2(ex3)

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