Arrays
Largest Element
Find the largest element in an array.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Find the largest element in an array.
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
int max = arr[0];
for (int i = 1; i < n; i++)
if (arr[i] > max) max = arr[i];
printf("Largest = %d\n", max);
return 0;
}
5
3 7 1 9 4
Largest = 9