Skip to content

Instantly share code, notes, and snippets.

@narenaryan
Last active October 12, 2023 18:17
Show Gist options
  • Select an option

  • Save narenaryan/b0bca3842489a390080a8b9728afe64a to your computer and use it in GitHub Desktop.

Select an option

Save narenaryan/b0bca3842489a390080a8b9728afe64a to your computer and use it in GitHub Desktop.
#include <stdio.h>
int find_max(int arr[], int size) {
int max = arr[0];
for (int i = 1; i < size; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
return max;
}
int main() {
int arr[] = {5, 10, 3, 8, 15};
int size = sizeof(arr) / sizeof(arr[0]);
int max = find_max(arr, size);
printf("Maximum element in the list: %d\n", max);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment