C Program to Find Largest Number in an Array

In this program, you will learn to find largest number in an Array. An array is a collection of homogeneous (same type) data items stored in contiguous memory locations. For example if an array is of type “int”, it can only store integer elements and cannot allow the elements of other types such as double, float, char etc.

Source Code
int largest(int[], int);
int main()
    int a[5], i;
    printf("Enter 5 array elements\n");
    for(i=0; i<5; i++)
        scanf("%d", &a[i]);
    printf("Largest element is %d", largest(a, 5));
    return 0;
int largest(int t[], int n)
    int max, i;
    max = t[0];
    for(i=1; i<n; i++)
        if(max < t[i])
            max = t[i];
    return max;
Enter 5 array elements
Largest element is 80

"Coding Hub - Learn to code" app now available on Google Play Store