Find Largest Element in Array C Program

By | October 28, 2015

C Program To Find Largest Element in Array

Learn How To Find Largest Element in Array in C Programming Language. It is important that we should know How A For Loop Works before getting further with the C Program Code.

To Find Maximum Element or the Largest Element in an Array, we need to assign the First Element ( Index 0 ) as the Maximum. Then, Compare every other Element with the Maximum. If the Element is Greater than Maximum, then assign it to Maximum.

Also Read: How To Find Minimum Element in 1-Dimensional Array in C

Note: This C Program To Find Largest Element in an Array is developed in Linux Ubuntu Operating System and compiled with GCC Compiler.

C Program To Find Largest Element in Array without Function

#include<stdio.h>

int main()
{
    int arr[10], count, maximum;
    printf("\nEnter 10 Elements in Array:\t");
    for(count = 0; count < 10; count++)
    {
        scanf("%d", &arr[count]);
    }
    printf("\nElements in Array are:\n");
    for(count = 0; count < 10; count++)
    {
        printf("%d\t", arr[count]);
    }
    printf("\n");
    maximum = arr[0];
    for(count = 0; count < 10; count++)
    {
        if(arr[count] > maximum)
        {
            maximum = arr[count];
        }
    }
    printf("\nMaximum Element in Array : %d\n", maximum);
    printf("\n");   
    return 0;   
}

Output

C Program To Find Largest Element in Array without using Function

In case you get any Compilation Errors with this C Program Code To Find Maximum Element of 1 Dimensional Array or if you have any doubt about it, let us know about it in the Comment Section below.

Let's Discuss