C PROGRAM TO FIND LARGEST / BIGGEST NUMBER IN ARRAY
#include<stdio.h> #define MAX 25 //maximum size of array is 25 main() { int i,n,LargeNo,arr[MAX]; printf("*** C PROGRAMS BLOG ***"); printf("\n>>> Program to find Largest element in array <<<"); printf("\n\n Enter the size of array: "); scanf("%d",&n); //taking size of array as input from user printf("\n Enter the %d elements of array: \n",n); //taking input all the elements of array using for loop for(i=0;i<n;i++) { printf("\n arr[%d]:",i+1); scanf("%d",&arr[i]); } LargeNo = arr[0]; for(i=0;i<n;i++) { if(arr[i]>LargeNo) { LargeNo = arr[i]; } } //printing the largest element in array printf("\n The Largest Element in the Array is: %d ",LargeNo); getch(); }
Explanation : The above program is to find the largest element in the given array of elements. Here we are using declaring the maximum size of array as 25 using #define directive .
Sample Output :
Good
ReplyDeleteHere is a link for C/C++ programs and pointer programs. This may be useful for you.
C/C++ Programs
Nice...you can also learn C programming from...
ReplyDeleteLearn C with examples
Basic C programming examples
C pattern programming examples
C Arrays examples
Loops in C examples
if-else in C with examples
Strings in C with examples and many more...