- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to find largest element in an array in C++
In this tutorial, we will be discussing a program to find the largest element in an array.
For this, we will be provided with an array. Our task is to find the largest number from the elements inside the array.
Example
#include <bits/stdc++.h> using namespace std; //finding largest integer int largest(int arr[], int n){ int i; int max = arr[0]; //traversing other elements for (i = 1; i < n; i++) if (arr[i] > max) max = arr[i]; return max; } int main(){ int arr[] = {10, 324, 45, 90, 9808}; int n = sizeof(arr) / sizeof(arr[0]); cout << "Largest in given array is " << largest(arr, n); return 0; }
Output
Largest in given array is 9808
- Related Articles
- C++ Program to Find Largest Element of an Array
- Python Program to find largest element in an array
- C# Program to find the largest element from an array
- Python Program to find the largest element in an array
- C# Program to find the largest element from an array using Lambda Expressions
- Swift Program to Find Largest Array Element
- Kth Largest Element in an Array
- Java program to find Largest, Smallest, Second Largest, Second Smallest in an array
- C++ Program to Find kth Largest Element in a Sequence
- Java program to find the largest number in an array
- Program to find out the index in an array where the largest element is situated in Python
- C program to find the second largest and smallest numbers in an array
- C# program to find maximum and minimum element in an array
- C# program to find the last matching element in an array
- Kth Largest Element in an Array in Python

Advertisements