How to Find Largest Number in an Array in C++? Last Updated : 13 Feb, 2024 Comments Improve Suggest changes Like Article Like Report In C++, arrays are used to store the collection of similar elements to be stored in adjacent memory locations. They can store data of any type such as int, char, float, etc. In this article, we will learn how to find the largest number in an array in C++. For Example,Input: myVector = {1, 3, 10, 7, 8, 5, 4} Output: Largest Number = 10Find the Largest Number in an Array in C++ To find the largest number in an array, we can use the std::max_element() function that takes the range in which it has to search for the max element as the arguments. The syntax of max_element() is: max_element(begin, end); Here, the begin is the pointer or iterator to the start of the range and the end is the pointer or iterator to the end of the range. This function will return the pointer or iterator to the maximum element in the range. C++ Program to Find the Largest Number in an Array in C++ C++ // C++ program to find the largest number in an array // without using std::max_element #include <algorithm> #include <iostream> using namespace std; int main() { // Initialize the array int arr[] = { 1, 45, 54, 71, 76, 12 }; int n = sizeof(arr) / sizeof(arr[0]); // Find the largest element in the array int max_num = *max_element(arr, arr + n); // Output the result cout << "Largest number in the array is: " << max_num << endl; return 0; } OutputLargest number in the array is: 76 Time complexity: O(n), where n is the number of elements in the array.Space complexity: O(1) Comment More infoAdvertise with us Next Article How to Find Largest Number in an Array in C++? anuragvbj79 Follow Improve Article Tags : C++ Programs C++ cpp-array CPP Examples Practice Tags : CPP Similar Reads How to Find the Mode of Numbers in an Array in C++? Mode of any dataset is the item that occurs most frequently in it. In this article, we will find the mode of numbers in an unsorted array in C++. For Example,Input: myArray = { 1, 2, 3, 4, 5, 2, 3, 2, 2, 4, 2 } Output: Mode : 2Finding Mode of Array Elements in C++To find the mode of the array elemen 2 min read How to Find the Mode in a Sorted Array in C++? The mode of the given numbers can be defined as the value that occurs the most in the given dataset or the value with the highest frequency. In this article, we will discuss how to calculate the mode of the numbers in a sorted array in C++. Example: Input: myVector = {1, 2, 2, 3, 3, 3, 4, 4, 5} Outp 3 min read How to Find the Smallest Number in an Array in C++? In C++, arrays are the data types that store the collection of the elements of other data types such as int, float, etc. In this article, we will learn how to find the smallest number in an array using C++. For Example,Input: myVector = {10, 3, 10, 7, 1, 5, 4} Output: Smallest Number = 1Find the Sma 2 min read How to Find the Range of Numbers in an Array in C++? The range of numbers in an array means the difference between the maximum value and the minimum value in the given array. In this article, we will learn how to find the range of numbers in an array in C++. For Example, Input: myArray = {5,10,15,30,25}; Output: Range: 25Range Within an Array in C++To 2 min read How to Find the Mode in a 2D Array in C++? A mode is a number that occurs most frequently in comparison to other numbers in a given dataset. In this article, we will find the mode in a 2D array of integers in C++. Input:myArray = { {1, 2, 2, 3}, {3, 4, 5, 5}, {5, 6, 7, 8} }Output: 5Mode in 2D ArrayTo find a mode of numbers in a 2D array, we 2 min read How to Find the Third Smallest Number in an Array in C++? In C++, an array is the collection of similar data elements that are stored in the contiguous memory location and we can access these elements directly by their index value. In this article, we will learn how to find the third smallest element in an array in C++. If there is no third smallest elemen 2 min read How to Find the Second Smallest Element in an Array in C++? In C++, arrays are data structures that store the collection of data elements of the same type in contiguous memory locations. In this article, we will learn how to find the second smallest element in an array in C++. Example:Input:myArray = {10, 5, 8, 2, 7, 3, 15};Output:The second smallest element 3 min read How to Find the Range of Values in a 2D Array in C++? In C++, 2D arrays are also known as a matrix, and the range of numbers in a 2D array means the maximum and the minimum value in which the numbers lie in the given 2D array. In this article, we will learn how to find the range of numbers in a 2D array in C++. For Example, Input: my2DArray= {{80, 90, 2 min read C++ Program to Find Largest Element in an Array In this article, we will learn to write a C++ program to find the largest element in the given array arr of size N. The element that is greater than all other elements is the largest element in the array. Recommended PracticeHelp a Thief!!!Try It! One of the most simplest and basic approaches to fin 2 min read How Can I Efficiently Sort a Large Array in C++? In C++, sorting an array means rearranging the elements of an array in a logical order. In this article, we will learn how to efficiently sort a large array in C++. Example: Input: myArray = {5, 2, 3, 1, 4......};Output: Sorted array is : 1 2 3 4 5 ....Sorting a Very Large Array in C++ To efficientl 2 min read Like