Programming Code Center(PCC)
[C]

(PCC)::[How-to-write-a-C-Program-to-Find-Largest-Element-in-an-Array]::[c]

File Name : Largest_Element_Array.c

//Find the Largest Element in an array
#include <stdio.h>
int main() {
    int i, n;
    float arr[100];
    printf("Enter the number of elements (1 to 100): ");
    scanf("%d", &n);

    for (i = 0; i < n; ++i) {
        printf("Enter number%d: ", i + 1);
        scanf("%f", &arr[i]);
    }

    // storing the largest number to arr[0]
    for (i = 1; i < n; ++i) {
        if (arr[0] < arr[i])
            arr[0] = arr[i];
    }

    printf("Largest element = %.2f", arr[0]);

    return 0;
}

Output :

Largest_Element_Array.jpg