C Programming
- Print integer
- Add & subtract
- Odd & even
- Multiply & divide
- Check vowels
- Letter grade program
- Leap year program
- Sum of digits
- Prime numbers
- Sum of numbers
- Find factorial
- Fibonacci series
- Fibonacci triangle
- Number triangle
- Alphabet triangle
- Armstrong numbers
- Palindrome numbers
- Swap number
- Reverse number
- Decimal to binary
- Assembly code in C
- Matrix multiplication
- HCF & LCM
- nCr & nPr
- Print pattern
- Floyd’s triangle
- Pascal triangle
- Count digits
- Strong numbers
- Perfect numbers
- Sum of natural number
- Binary to decimal
- Decimal to octal
- Octal to decimal
- Binary to octal
- Octal to binary
- Add using pointer
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Binary search
- Linear search
- Largest element of array
- Smallest element of array
- Reverse Array
- Variable size & limit
- ASCII value of character
- Sum of array elements
- Number of element in array
- Merge two array
- Insert element in array
- Delete element from array
- Add two matrix
- Transpose matrix
- Print string
- Reverse string
- Delete vowels
- Sort string
- Remove spaces
- Swap string
- Random numbers
- Print date & time
- Print IP address
- Shut down computer
Find largest element in an array using C
Here we see C program to find largest element in an array. At first we assume that the first element is the largest. Then we will compare it with the adjacent element and swap them if the second number is greater than the first one.
We can find the largest number of an array using function, pointers or without them. Let’s see some C program to find the largest element in an array.
C program to find largest element in array
// find largest element of an array by c program
#include <stdio.h>
int main(){
int i, number_array[50], arr_size, index_no = 0;
printf("Enter number of integers of the array : ");
scanf("%d", &arr_size);
printf("Enter %d array elements bellow : \n", arr_size);
for(i = 0; i < arr_size; i++){
scanf("%d", &number_array[i]);
}
for(i = 1; i < arr_size; i++){
if (number_array[i] > number_array[index_no]){
index_no = i;
}
}
printf("\nLargest number at location %d which is = %d.\n", index_no + 1, number_array[index_no]);
return 0;
}
Output of largest element program

You can also use function or recursion to make the above program. However, if the maximum number remains more than one time then we can determine that how many time it occurs in the array. Simply we can count the occurrence in another variable and print that. Try this in your own.
Find largest number using pointers in C
// find maximum element using pointers in c
#include <stdio.h>
int main(){
int x, num_array[50], *max_num, arr_size, indx = 1;
printf("Enter how many element you have for array : ");
scanf("%d", &arr_size);
printf("Enter all the array elements : \n");
for(x = 0; x < arr_size; x++){
scanf("%d", &num_array[x]);
}
max_num = num_array;
*max_num = *num_array;
for (x = 1; x < arr_size; x++){
if (*(num_array + x) > *max_num){
*max_num = *(num_array + x);
indx = x + 1;
}
}
printf("\nLargest number is at location %d and it is = %d.\n", indx, *max_num);
return 0;
}
Output of this program
Enter how many element you have for array : 10
Enter all the array elements :
23 54 54 86 95 46 99 54 22 36
Largest number is at location 7 and it is = 99.
Previous page:Â Linear search
Next page:Â Smallest element in array