C Program to Find Largest Element of an Array

#include <stdio.h>
#include <conio.h>

void main()
{
    int n,a[100],i,temp;
    printf("Enter quantity (1 to 100): ");
    scanf("%d",&n);
    printf("Enter %d numbers\n",n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    temp=a[0];
    for(i=1;i<n;i++)
    {
        if(temp<a[i])
            temp=a[i];
    }
    printf("Largest value is %d",temp);
    getch();
}


OUTPUT:

No comments:

Post a Comment