C Program to Find Largest Number from Array using Function

C Program to Find Largest Number from Array using Function:
If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().



#include<stdio.h>
main()
{
    int a[10];
    int i,b;
    int largest(int [],int);
    printf("Enter 10 array element\n");
    for(i=0;i<10;i++)
      scanf("%d",&a[i]);

    b=largest(a,10);
    printf("The largest number from array is %d",b);
}

int largest(int a[],int size)
{
    int max=0,i;
    for(i=0;i<size;i++)
    {
        if(a[i]>max)
        {
            max=a[i];
        }
    }
    return(max);
}

OUTPUT:

Enter 10 array element
1 7 5 14 74 95 25 18 35 25
The largest number from array is 95

Leave a Reply

Your email address will not be published. Required fields are marked *

12 − 5 =