My Project - Video Waker Alarm
Get Video alarm on Google Play

c program to find largest(maximum) number in array


c program to find largest number in array. Array is a collection of similar types element. We can find maximum or minimum element in an array by using comparison operator. i.e traversing all the elements and comparing these elements pair wise one by one. You can also find c program for different array examples.

c program to find largest number in array.

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

int main()
{
     int mat[20];
     int s,max;
     printf("\nSize of your Array is : ");
     scanf("%d",&s);
     printf("\nEnter your %d element of an array : \n", s);

     for(int i=0;i<s;i++)
     {
          scanf("%d",&mat[i]);
     }
     max=mat[0];

     for(int i=1;i<s;i++)
     {
          if(max < mat[i])
          max = mat[i];
     }

     printf("\nmaximum value element from given %d element is : %d",s,max);
     getch();
     return 0;
}

Output of c program to find largest number in array:

c program to find largest number in array

2 thoughts on “c program to find largest(maximum) number in array”

Comments are closed.