It’s the largest element or maximum element in an array C program that inputs numbers from the user, and stores these numbers in an array, then using the maximum element algorithm to find the maximum element in an array, and print result on the screen.
To understand this program, it’s better you should know the following topics:
Program (1): to find maximum element in an array, C programming.
#include<stdio.h> #include<conio.h> void main() { int a[100],i,max,n; printf("Enter the number of elements(upto 100) to be entered in the list : ",n); scanf("%d",&n); //accepting values into array for(i=0;i<n;i++) { printf("Enter %d element : ",i+1); scanf("%d",&a[i]); } //logic to find maximum element max=a[0]; for(i=1;i<n;i++) { if(max<a[i]) max=a[i]; } //Printing the maximum element printf("maximum element is %d",max); getch(); }
Output (1)
Enter the number of elements(upto 100) to be entered in the list : 3 Enter 1 element : 2 Enter 2 element : 100 Enter 3 element : 23 maximum element is 100