C Program to Find Largest Element in Array

#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int large, array[50], size, i;
    printf("Enter Array Size  : ");
    scanf("%d",&size);
    printf("\n Enter array elements : ");
    for(i=0; i<size; i++)
    {
        scanf("%d",&array[i]);
    }
    printf("Searching for largest number ...\n\n");
    large=array[0];
    for(i=0; i<size; i++)
    {
        if(large<array[i])
        {
            large=array[i];
        }
    }
    printf("Largest Number = %d",large);
    getch();
}


Run:

No comments:

Post a Comment

100 C Programs with Code and Output

Program 1: C Program To Read Two Numbers And Print The Sum Of Given Two Numbers. Program 2: C Program To Read Three Numbers And Prin...