how to get the largest number in a c++ array

#include <iostream>
using namespace std;
int main(){
   //n is the number of elements in the array
   int n, largest;
   int num[50];
   cout<<"Enter number of elements you want to enter: ";
   cin>>n;
   
   /* Loop runs from o to n, in such a way that first
    * element entered by user is stored in num[0], second 
    * in num[1] and so on. 
    */
   for(int i = 0; i < n; i++) {
      cout<<"Enter Element "<<(i+1)<< ": ";
      cin>>num[i];
   }
   // Storing first array element in "largest" variable
   largest = num[0];
   for(int i = 1;i < n; i++) {
      /* We are comparing largest variable with every element
       * of array. If there is an element which is greater than
       * largest variable value then we are copying that variable
       * to largest, this way we have the largest element copied
       * to the variable named "largest" at the end of the loop 
       *
       */
      if(largest < num[i])
         largest = num[i];
   } 
   cout<<"Largest element in array is: "<<largest;
   return 0;
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
highest in array c++ highest number in array cpp return the largest number in an array c++ c++ finding the largest number in an array c++ find the highest value in an array find the largest number in array c++ c++ biggest number in array C++ program to find largest and second largest number in an array C++ program to find the largest and second largest number present in an array using stl print largest number in array and smallest number using cpp find the highest element in an array in c++ largest number of elements for array c++ largest value for array c++ find largest number in c++ c++ to find largest number in array how to find the largest number in c++ using fun how to find the largest number in c++ how to get the largest number in an array c++ largest array size cpp find largest number in array c++ using function C++ program to find the largest and second largest number present in an array how to find highest number in an array C++ find largest and smallest number in array c++ c++ Write a program to get the largest number from an array. find biggest number in c++ array function to find biggest element in array in c++ how to find biggest element in array in c++ how to find biggest elemt in array in c++ c++ program for finding largest smallest and reapaet numbers in array finding the largest element in an array c++ program to find largest element in an array c++ find smallest and largest value in array c++ find the biggest number in array c++ how to create biggest number from array elements in c++ how to create biggest number from array's element in c++ get biggest number in array c++ function get biggest number in array c++ can max function be used to get largest number in array c++ find the number with the highest value within an array c++ make a function which find largest number in array inc++ making function for finding largest number in array c++ how to find the largest number in an array in c++ find the largest and smallest number in an array in c++ how to declare a biggest int array in c++ largest number formed from an array c++ largest array c++ C++ get highest int in array how to find the highest number of an array in c++ finding the largest number in an array c++ get highest value in array c++ c++ program to find largest number in an array using function How can i find the biggest number in an array with c++ largest array size c++ c++ program to find the largest and smallest element in an array c++ program to find the largest number in an array highest value of array cpp find the largest number from array cpp find the largest number in an array in c++ c++ find the largest single number in an array how to get the highest number in an array c++ how to find the largest element in an array cpp c++ find highest value in array stl function to find largest number in array c++ function to find largest number in array c++ how to check the largest number in array c++ find highest and lowest number in array c++ C++ arry find highest value how to get the biggest number out of an array of numbers in c++ how to find the greatest element in an array c++ largest and smallest number in array c++ get the highest value in array c++ numbers from smallest to biggest array c++ find the largest number in an array c++ print largest number in array c++ largest array size in cpp highest value in array c++ c++ largest in array std c++ largest in array find biggest element in an array c++ finding the biggest number c++ array return largest value in arrat c++ how to find the index of the largest numbers in an array c++ c++ function to find largest number in array how to find the index of the largest number in an array c++ how to find the largest number in an array c++ in a function find largest number in array c++ function c++ create a largest number in array how to find the largest value of an array c++ how to find the largest variable of an array c++ how to find biggest number in array c++ c++ largest element in array largest element in array c++ inbuilt function c++ get highest number in array how to find the largest value in a list c++ the maximum value in an array c++ the maximum value in an array +c+ find maximum array c++ find smallest number in array c++ find the largest number in a single input in C++ c++ find max in an array Program to find largest element in an array finding the largest number in an array c how to find the biggest value in array in c++ how to find the smallest number in an array c++ how to find the largest number by c++ how to find the maximum value in an array c++ largest number and smallest number in array in c++ find the largest element of an array max number of elements in array c++ greatest value on array c++ c++ find biggest number in array find the biggest element in c++ check largest number in array find max integer in array c++ print maximum element of an array in cpp largest value in set in c++ find 3 largest numbers in an array in c++ c++ largest number in array find max numbeer in c++ maximum element in the array in c++ how to find the biggest number in an array c++ cpp how to find max value in array using set in c++ to find largest element smaller than k how to find maximum element in an array in c++ find max number in array cpp how to print maximum element in an array in cpp largest element in array c++ c++ program to find largest element of an array how to output maximum element in an array c++ c++ how to find the largest number in an array c++ code to find the max element in an array c++ array print largest element find the largest value in an array c++ finding the biggest number in an array c++ how get large number in array c++ largest number in cpp max value in array c++ largest four element in an array in c++ largest number in an array c++ stl largest number in an array c++ finding largest value in array c++ find largest value in array c++ find largest number in array C++ function to find max value in array c++ c++ find largest number in array function to find highest number in array c++ c++ program to find max value in array largest number in array c++ program to find largest and smallest and medium number in an array c++ code for largest elemnet in how to find the max vlaue in an array c++ max value from array c++ cpp biggest value of array find maximum of an array c++ max in an array c++ find highest number array c++ find max iun array c++ find the greatest number in an array in C++ find the largest element of an erray find the max value in an array c++ biggest element in array in c++ find maximum un array c++ finding maxium within array c++ largest array element c++ find maximum in c++ array c++ program to find index of largest element in an array largest number c++ array largest number array c++ finding the largest number in an array in c++ find max value in array c++ how to find largest number in array c++ function to find largest term in array c++ how to find highest number in array c++ find the largest element in an array c++ how to get address of largest number in array c++ how to find the largest number in array c++ how to find max number in array in c++ finding max number in a array c++ c++ program to find largest number in an array finding the highest value in an array c++ find largest number in array using cclog c++ find the largest value in an array cpp largest number in array c++ find the biggest number in a array c++ code to find maximum number in an array c++ find largest number in array c++ find max in array c++ how to find highest value in c++ how to find highest value in array c++ how to find largest number in c++ c++ find max in array c++ code to find max of array how to find the largest number in an array c++ findlargest c++ program in c++ to find biggest number in two arrays get max number in array c++ how to find biggest number array c++ how do i find the maximum number in an array on c++ find highest number in array c++ how to find max number in array c++ how to get the largest number in a c++ array
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source